比如我現在有兩個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
提交
取消