-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
When using DbContext pooling, the DbContext can't have a constructor which takes anything but DbContextOptions. I would like to be able to inject singleton services - can this be allowed?
The example of how to use pooling in a multi-tenanted application is useful, however in my app we have a tenant ID accessor which is a singleton service that acts similarly to HttpContextAccessor. As such I was hoping to be able to inject this into my DbContext, even with pooling enabled. It's much nicer to be able to declare the dependencies in the constructor, and because it's a singleton service I don't think it matters that the DbContext instance is pooled?
If DbContext pooling is going to be pushed more aggressively, it might be nice to review ways to make it easier to use - such as this.