Using Entity Framework 6.0 I got this message. This problem occurs when mostly in Async environment. This is due to a reader (in the same DBContext) that is still open, while another reader tries to open an new one. Typically this is a async issue.
In my MVC 5 app I have a Async call to my webapi. My problem was that I created a second repository object in a method, while the first repository was created by Unity Dependency Injection Framework was not finished reading.
In stead of newing the repository up in the method I injected it in the constructor and all issues where solved.
A better solution:
Add MultipleActiveResultSets=True to the connectionstring of the database.
Strange thing today. I have a MVC 5 webapp, that has Webapi capabilities used. Problem is that I get old data when retrieving it from a Webapi controller, but fresh data when retrieving directly from the database.
The issue was in the user of automapper. I had automapper map a datetime taking the timezone in account. I had to search in the database to get the right timezone. There the old value was presented. Probably due to Dependency Injection, there was a different databasecontext loaded, that did not see changes made.
Solution: quit using automapper and map the properties manual in my own Mapper class.
After updating my nuget packages my build of the test project was failing, without any error reported in the build output window.
First of all you can turn on verbose logging:
- Project and Solutions
- Build and Run
- Set these to options to Diagnostic:
- MSBuild project build output verbosity
- MSBuild project build log file verbosity
Probably you’ll see the error appearing in you build log file of in the build output file.
In my case the System.web.mvc reference was updated, but the fake assembly that I had generated was not updated and one assembly was missing.