Cannot access a disposed object in ASP.NET Core working with DbContext



Bump into this error and found out the reason you cannot spin up a task to run a injected DbContext which normally injected by WebAPI dependency injection of a DbContext.

Solution

Create your dbcontext manually using code below (instead of using DbContext passed in the controller)







Comments

Popular posts from this blog

mongosh install properly

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20