求教多库的使用方法!
AS-D opened this issue · comments
AS commented
求教详细的多库使用方法,不知道为何我使用多库时
老是报错
AS commented
Startup 文件
services.Configure(options =>
{
options.TagName = "db0";
options.ConnectionString =
"Data Source=F:\EF6.db;Version=3;";
//options.ModelAssemblyName = "Zxw.Framework.Website.Models";
});
services.AddDbContextFactory(factory =>
{
factory.AddDbContext<SQLiteDbContext>(new DbContextOption()
{
TagName = "db1",
ConnectionString = "Data Source=F:\\EF6.db;Version=3;"
});
factory.AddDbContext<SqlServerDbContext>(new DbContextOption()
{
TagName = "db3",
ConnectionString = "data source=serverb;initial catalog=NetCoreDemo;persist security info=True;user id=sa;password=sa.123;multipleactiveresultsets=True;application name=EntityFramework",
});
factory.AddDbContext<SqlServerDbContext>(new DbContextOption()
{
TagName = "db2",
ConnectionString = "data source=serverb;initial catalog=TestDb1;persist security info=True;user id=sa;password=sa.123;multipleactiveresultsets=True;application name=EntityFramework",
});
});
services.AddScoped<IDbContextCore, SQLiteDbContext>(); //注入EF上下文
vzeng commented
AS commented
vzeng commented
AS commented
代码我上传到github了,麻烦您有时间帮忙看一下。谢谢https://github.com/AS-D/Zxw-
vzeng commented
暂不支持同时注入多个同类型的数据库链接,这个功能后续会加上
AS commented
奥奥,好的
AS commented