1

I have a product that used an old version of Entity Framework (don't know the version) that I have to update to EF6. In the older EF there used to be a method on an entity called Refresh to update the table contents. For example:

EFDataEntity.Refresh(RefreshMode.StoreWins, EFDataEntity.TableOne);

to update the EF table TableOne so that EFDataEntity.TableOne had the latest data from the SQL table.

On EF6 this method no longer exists. I tried this:

EFDataEntity.Entry(EFDataEntity.TableOne).Reload();

but it throws exception

The entity type DbSet`1 is not part of the model for the current context.

How does one refresh the table in EF6?

Revtim
  • 11
  • 2
  • Did you pass an _instance_ of an entity? What is `BEDataEntity.TableOne`? Based on your naming, `BEDataEntity` looks like a context and `TableOne` seems to be a `DbSet<>` – Chris Dunaway Oct 02 '19 at 22:02
  • Sorry, the correct code should be EFDataEntity.Entry(EFDataEntity.TableOne).Reload(); I fixed it in the original question – Revtim Oct 03 '19 at 13:26
  • To answer your questions, EFDataEntity is the entity framework object, TableOne is a table in the database. – Revtim Oct 03 '19 at 13:55

1 Answers1

0

You can either dispose your current context and create a new one or if you don't want to do this for some reason you can also do this: yourcontext.Entry(yourEntity).Reload() Microsoft Docs || Working with DbContext

  • Thanks, but I think that refreshes the entire entity, when I just want to refresh a single table. In any case, I tried that, and I get Exception "{"The entity type BEEnterpriseEntities is not part of the model for the current context."} BEEnterpriseEntities is the type of my EF object. – Revtim Oct 02 '19 at 20:16