I have an EF object that I pull from db. Then I do the update of the corresponding row in the database through a function call that uses another DBContext
. After this update, I would like to reload the contents of the object with the updated contents, however, the contents are cached in the EF context. Here's a sample code (I removed some unbound fluff to make it easier):
using (UmbrellaEntities context = new UmbrellaEntities()) { var umbrella = (from u in context.Umbrellas where u.umbrellaId == umbrellaId && !u.deleted select u).Single(); int oldVersion = umbrella.Version; updateUmbrellaVersions();
I find that I can use the new context to pull out the updated context, but this is inefficient.
using (UmbrellaEntities context = new UmbrellaEntities()) { var umbrella = (from u in context.Umbrellas where u.umbrellaId == umbrellaId && !u.deleted select u).Single(); int oldVersion = umbrella.Version; updateUmbrellaVersions();
Is there a way to reload the content immediately after the update?
source share