entity-frameworkrefreshreloaddirty-dataobjectstatemanager

ObjectContext.Refresh()?


How to update ALL the dirty entities from the data store, and reset their changed values to the original store value?

The method ObjectContext.Refresh requires as a parameter the entities to be refreshed.


Solution

  • The following usually works:

    Context.Refresh(RefreshMode.StoreWins, _
        Context.ObjectStateManager.GetObjectStateEntries())
    

    It sometimes causes problems with EntityRelations. look at my comment for further details.