如何在控制器中使用多个DBContext,我尝试以不同方式重载构造器?
某些控制器:
public C1(DBContext1 a, DBContext2 b, DBContext3 c)
{
}
//public C1(DBContext1 a)
//{
//}
//public C1(DBContext2 b)
//{
//}
//public C1(DBContext3 c)
//{
//}
StartUp.cs:
services.AddDbContext<DBContext1>(options =>
options.UseSqlServer(new string(K.ConnectionString))
);
services.AddDbContext<DBContext2>(options =>
options.UseSqlServer(new string(K.ConnectionString))
);
services.AddDbContext<DBContext3>(options =>
options.UseSqlServer(new string(K.ConnectionString))
);
我找到this,但它似乎已过期
错误(前台调用构造函数时):
执行请求时发生未经处理的异常。