Want to write a generic audit code in my subclass of DbContext.
foreach (var entry in this.ChangeTracker.Entries<MyClass>()) { if (entry.State == EntityState.Modified) { var entityProperties = entry.Entity.GetType().GetProperties(); foreach (var entityProperty in entityProperties) { DbMemberEntry propertyEntry = entry.Member(property.Name); if (propertyEntry is DbPropertyEntry) {
1) If I change only the link property, the value of entry.State is "No change."
2) Even if item 1 is set to Modified, the DbReferenceEntry class does not seem to have the IsModified property and the original value.
I guess this is possible because EF should keep track of this.
Can anyone help?
Thanks Ben
user140628
source share