Is it possible to add more than 1 DbContextFactory, for the same DbContext, to the services collection in an ASP.NET Core application?
For example, I am trying the following code ...
services
.AddDbContextFactory<WibWorkspaceContext, WibWorkspaceContextFactory>();
services
.AddDbContextFactory<WibWorkspaceContext, WibWorkspaceSystemContextFactory>();
I want two different factories for the same DbContext. One factory always signs in using a SQL "admin" account and the other uses user-specific accounts.
I can't seem to figure out how to get this to work, though. How can I specify which one to use on the side of things that grab the service? For example, here's a constructor receiving the service - how does it know which one to use?
public async Task Invoke(HttpContext httpContext, IDbContextFactory<WibWorkspaceContext> contextFactory, IConfigu开发者_开发技巧ration configuration)
Is this possible? Thanks.
精彩评论