Search code examples
entity-framework-4entity

How to get original values of an entity in Entity Framework?


In EF 4.0, if I understand it right, there are two type of values in Entity : current values and original values.
We can set original values by calling ApplyOriginalValues(TEntity) method but how to get original values ?


Solution

  • You can access them through ObjectStateEntry

    var originalValues = context
             .ObjectStateManager.GetObjectStateEntry(myEntity).OriginalValues;