Use both AddDbContextFactory() and AddDbContext() extension methods in the same project
It is, it’s all about understanding the lifetimes of the various elements in play and getting those set correctly. By default the DbContextFactory created by the AddDbContextFactory() extension method has a Singleton lifespan. If you use the AddDbContext() extension method with it’s default settings it will create a DbContextOptions with a Scoped lifespan (see the … Read more