比如我现在有两个DBContext :DbContextA,DbContextBservices.AddDbContextPool<DbContextA>(options => { //options.UseInMemoryDatabase("adult"); options.UseSqlServer(Configuration.GetConnectionString("AdultDbStr")); }); services.AddDbContextPool<DbContextB>(options => { //options.UseInMemoryDatabase("Identity"); options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); });当我激活DbContextA的实例时会说ArgumentException:Expression of type Microsoft.EntityFrameworkCore.DbContextOptions [DbContextA]cannot be used for constructor parameter of typeMicrosoft.EntityFrameworkCore.DbContextOptions [DbContextB]当我将DbContextPool换成DbContext就没有问题了。我尝试过将注入顺序调换,结果是用DbContextPool只会记住最后一个注入的,前边的都是被覆盖掉。请问这是为什么?环境:.Net Core 2.1 RC1
添加回答
举报
0/150
提交
取消