dbUpdateConcurrencyException on simple delete after loading

.net c# concurrency entity-framework entity-framework-6

Accepted Answer

The DBContext required by the test setup and teardown is being loaded when the test setup executes, which results in this error. Because the first context was loaded during setup, it is based on a "old" version of the database, the one from before the test was run. A different context performs a database change between setup and teardown.

The issue can be resolved by not having teardown utilize the same DBContext as setup. In order for Teardown's new DBContext to be loaded using the most recent data, it should be loaded from scratch.

When the customers to be deleted were loaded from the database, I had thought that the data's status at that point was what really mattered. But it seems that what counts is the data's state at the moment the DBContext was loaded.

0
11/16/2015 3:33:57 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow