With ObjectContext:
var objContext = new ObjContextEntities(); var accountType = objContext.AccountTypes.FirstOrDefault(x => x.Id == 0); accountType.Name = "ABC"; var stateEntry = objContext.ObjectStateManager.GetObjectStateEntry(accountType); Console.WriteLine(stateEntry.GetModifiedProperties().Count());
With DbContext:
var dbContext = new DbContextEntities(); var accountType = dbContext.DBAccountTypes.FirstOrDefault(x => x.Id == 0); accountType.Name = "XYZ"; var dbObjContext = ((IObjectContextAdapter)dbContext).ObjectContext; var stateEntry = dbObjContext.ObjectStateManager.GetObjectStateEntry(accountType); Console.WriteLine(stateEntry.GetModifiedProperties().Count());
I would like to switch to using DbContext, but I have code that depends on this function. Is this a known bug? Can anyone suggest an alternative approach? Thanks.
source share