是否允许多个DbContext
,或者它应该只是整个ASP应用程序中的一个?
我的Startup.cs
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddDbContext<PatientContext> (options => options.UseSqlite("Data Source=MyDatabase.db"));
services.AddDbContext<AdminAccountContext> (options => options.UseSqlite("Data Source=MyDatabase.db"));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
答案 0 :(得分:2)