In order to retrieve database column name, there are two methods: GetColumnBaseName
and GetColumnName
.
- What's the difference between them?
- Why
GetColumnName
requires StoreObjectIdentifier
with custom values for table name? Doesn't Metadata
know the table based on its parent PropertyEntry
property?
using var db = new TestContext();
var customer = await db.Customers.FirstAsync(c => c.Id == 1);
customer.Address = "Jon";
var entry = db.Entry(customer);
var modifiedProperty = entry.Properties.First( p => p.IsModified );
// Using "GetColumnName"
var baseName = modifiedProperty.Metadata.GetColumnBaseName();
// Using "GetColumnName"
// Doesn't Metadata know the table?
var id = StoreObjectIdentifier.Table("customer", schema: "dbo");
var columnName = modifiedProperty.Metadata.GetColumnName(id);