With EF4 CTP5 DbContext, what is the equivalent of this
public void Refresh(Document instance)
{
_ctx.Refresh(RefreshMode.StoreWins, instance);
}
I've tried this but it doesn't do the same thing, updating the instance
public void Refresh(Document instance)
{
_ctx.ChangeTracker.DetectChanges();
}
?
I found that the reload fails on proxy entities that have navigation properties.
As a work around, reset the current values and then reload like this:
The above doesn't work. Reload() method does not correctly refresh the entity from the database. It performs SQL select query but does not build proxies for the navigational properties. See the example below (I use the Northwind database in SQL Server with EF 5.1):
I may conclude that real refresh / reload of EF entity can be done by Detach + Find:
Nakov
You must use this: