Quantcast
Channel: entityframework Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1793

New Post: SaveChanges() and OnPropertyChange() do not like each other

$
0
0
I have a problem understanding how to deal with the problem I am facing.

All my entities have an identity property (Autoincrement). When I call DbContext.SaveChanges() (async or not), Id property is being updated by the EF for new entities. In the setter for Id property i call OnpropertyChnages("Id"), to notify View or ViewModel that Id has been updated.

In some situations this raises exception:

EntityMemberChanged or EntityComplexMemberChanged was called without first calling EntityMemberChanging or EntityComplexMemberChanging on the same change tracker with the same property name. For information about properly reporting changes, see the Entity Framework documentation.

If I comment out the property change notification, then the exception does not occur. The problem is that I need to know which properties have been updated by EF after SaveChanges has completed.

So, how are we suppose to deal with this problem - save changes and know what properties have been updated by EF behind scenes?

Viewing all articles
Browse latest Browse all 1793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>