Hi,
We have entity objects where 2 fields UpdateUserId and UpdateDate needs to be set if an object is modified. When I check the object's EntityState, it shows it as Modified even when it is not. Is there a better way to check if something has changed in the object?
Thanks,
Uday
Verifying if an entity object is modified
First, sorry for the delay.
You can try to find out which properties were modified:
However, an entity should not be marked as Modified if it wasn't modified explicitly.
Please check that your code does not modify the entities.
You can try to find out which properties were modified:
Code: Select all
var changed = context.ObjectStateManager.GetObjectStateEntries(EntityState.Modified);
foreach(var entry in changed) {
var properties = entry.GetModifiedProperties();
Please check that your code does not modify the entities.