【发布时间】:2020-10-01 00:59:52
【问题描述】:
我想为 myapp 使用两个数据上下文
services.AddDbContext<AuthenticationContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection")));
services.AddDbContext<DataContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MyConection"))
);
传递给 AuthenticationContext 构造函数的 DbContextOptions 必须是 DbContextOptions。注册多个 DbContext 类型时,请确保每个上下文类型的构造函数都具有 DbContextOptions 参数,而不是非泛型 DbContextOptions 参数。'
【问题讨论】:
-
能否请您更新每个 DbContext 的问题?
-
是的,我可以更新数据库
标签: asp.net-core