Answer the question
In order to leave comments, you need to log in
Entity Framework - how to update only one entity?
I have a certain model from the Entity Framework. It is necessary to somehow update only 1 entity (that is, fill 1 table with data from the database). For example , if you changed something in the database outside the program and only in one table, how can I update only 1 table?
I'm doing so far by simply recreating all the content: _dataContext = new MyMagnEntities();
Because I haven't found another way yet. How to do it right?
Answer the question
In order to leave comments, you need to log in
It is necessary to somehow update only 1 entity (that is, fill 1 table with data from the database). For example, they changed something in the database outside the program and only in one table, how can I update only 1 table
It could be something like this:
ObjectContext objectContext = ((IObjectContextAdapter)_dbContext).ObjectContext;
objectContext.Refresh(RefreshMode.StoreWins, _dbContext.SomeTable);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question