ObjectContext.Refresh()?

Shimmy Weitzhandler picture Shimmy Weitzhandler · Nov 17, 2009 · Viewed 28.6k times · Source

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.

Answer

Shimmy Weitzhandler picture Shimmy Weitzhandler · Nov 17, 2009

The following usually works:

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

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