I have used ApplyCurrentValues.
But don't really understand ApplyOriginalValues. How is it different from ApplyCurrentValues? When should I use it?
I have read the documentation. But still confused.
Each entity loaded from the database keeps two sets of values - original (those loaded form DB) and current (those you are modifying). These two sets are hold in ObjectStateEntry
. Usually each save is followed by accepting changes which takes current values and writes them to original values. If you know that you made changes to the entity outside of EF (for example by calling stored procedure with common ADO.NET EF) you can force EF to know about those changes without reloading the entity by using ApplyOriginalValues
. I think using this method is rather rare. For example I used ApplyOriginalValues
in this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With