Search code examples
entity-framework-4entity-framework-ctp5ef-code-first

Refresh entity instance with DbContext


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();
    }

?


Solution

  • You must use this:

    public void Refresh(Document instance)
    {
      _ctx.Entry<Document>(instance).Reload();
    }