datacontext - Entity framework data context not in sync with database? -


Then, this is the situation -

  • Enter an item in the database I call AddtoObject () And then call SaveChanges ().
  • Then, I call an archived procedure to update the currently recorded record.
  • Then, I call the changes () again. / Li>
  • When I query that the database has the correct update value, but there are no update values ​​in the entity framework context. The first time it never receives updated values.

    Does anyone have to face a similar problem? What am I doing wrong here?

    The problem is that EF does not know what your stored procedure is, how can it be? That work is done on SQL Server, so after the execution of your stored procedure, you will need to ask EF to issue the call and update the (and other related) frequency:

      context. Refresh (RefreshMode.StoreWins, myObject);   

    With the values ​​from the database, the StoreWins framework for overwriting values ​​in the instance tells.

Comments