You are currently browsing legacy 5.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Refresh an Entity

To update an entity with the latest changes from the server, use the Refresh method from Advanced session operations.


void Refresh<T>(T entity);
entity T Instance of an entity that will be refreshed


Employee employee = session.Load<Employee>("employees/1");
Assert.Equal("Doe", employee.LastName);

// LastName changed to 'Shmoe'

Assert.Equal("Shmoe", employee.LastName);


Refreshing a transient entity (not attached) or an entity that was deleted on server-side will result in a InvalidOperationException.