C#C
C#2y ago
Noriega

Exception about disposing DbContext

This exception I've been getting is so confusing since every other source I tried looking up for solutions doesn't exactly apply to my code. So, the exception I'm getting is that my db context gets disposed before I can use another operation on the db. Everywhere Ive checked for help had people screwing up asynchronous operations, which isnt the case for me. Here is my file for reference

- System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'ScathachDbContext'.

Am using pooled db context btw
Was this page helpful?