Lets say, i have an EntityObject called someProduct :
//Get the object
Product someProduct = someObjectContext.Product.First();
//At runtime at some point, recreate the ObjectContext
someObjectContext = new SomeObjectContext();
//Try to refresh someProduct on the new ObjectContext
someObjectContext.Refresh(RefreshMode.StoreWins, someProduct);
When the third line executes, it throws an exception:
The element at index 0 in the collection of objects to refresh has a null EntityKey property value or is not attached to this ObjectStateManager.
Is this the correct way to refresh the EntityObject on a newly create ObjectContext?
EDIT:
The reason for new ObjectContext is to refresh all the dirty EntityObjects.
First attach the entity to the context before refresh,
or
That should do it.