In ASP.NET Core application I can register DbContext through DI like this
services.AddDbContext(options => options.UseNpgsql(
Admittedly anecdotal, this is what I’ve learned. And it’s from a lazy KISS devotion. I avoided other complications and solved my issue of premature EF Core DbContext disposes w/o concern of pools, scopes etc. I was merely throwing together a POC w/o regard to async return values, chained up from the Controller to a Repository and so on, which all essentially returned “void”, i.e. literally the singular, “Task”. That caused iterations amongst my DbContext members in lower routines to inexplicably dispose of the underlying DbContext. All I had to do was make every async method return a Task
value and everything worked. EF Core don’t like async void return values.