Vishal
Vishal

Reputation: 12369

Entity framework data context not in sync with database?

So, here is the situation -

So has anyone faced a similar issue anytime ? What am I doing wrong here ?

Upvotes: 0

Views: 7070

Answers (1)

CodingGorilla
CodingGorilla

Reputation: 19842

The problem is that the EF does not know what your stored procedure is doing, how could it? That work is done at the SQL Server. So after your stored procedure executes, you need to ask EF to update that (and other related) instance by issuing a Refresh() call:

context.Refresh(RefreshMode.StoreWins, myObject);

The StoreWins tells the framework to overwrite values in the instance with values from the database.

Upvotes: 6

Related Questions