装了个Microsoft.EntityFrameworkCore.Sqlite 插件搞定,重新定义了Sqlite的DbContext如下
public class SqliteContentBase : Microsoft.EntityFrameworkCore.DbContext
{
static string dbPath1 = $"ask.db";
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={dbPath1}");
public Microsoft.EntityFrameworkCore.DbSet<AskContent> AskContent { get; set; }
}
实现了2种数据库的同时访问,搞来搞去搞好久。
本文介绍了如何通过安装Microsoft.EntityFrameworkCore.Sqlite插件,实现DbContext的定制,以便同时访问两种数据库,重点在于Sqlite数据库的配置和使用实例。
2125

被折叠的 条评论
为什么被折叠?



