_sqliteConnection = CreateDatabaseAndGetConnection();
services.Configure<AbpDbContextOptions>(options =>
{
options.Configure(context =>
{
context.DbContextOptions.UseSqlite(_sqliteConnection);
});
});
services.AddAbpDbContext<EBSYSDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
});
我这样配置,单元测试时,数据访问始终跑到 sqlite.
//注册数据库的服务
string connectionString = Configuration.GetConnectionString("firstContext");
string connectionString2 = Configuration.GetConnectionString("secondContext");
services.AddDbContext<firstContext>(options => options.UseMySql(connectionString));
services.AddDbContext<secondContext>(options => options.UseMySql(connectionString2));
谢谢您的回复,这样还是不行,在单元测试环境下还是跑到sqllite