首页 新闻 会员 周边

AbpVnext 单元测试怎么配置多个数据库

0
悬赏园豆:5 [待解决问题]

_sqliteConnection = CreateDatabaseAndGetConnection();

        services.Configure<AbpDbContextOptions>(options =>
        {
            options.Configure(context =>
            {
                context.DbContextOptions.UseSqlite(_sqliteConnection);
            });
        });
        
        services.AddAbpDbContext<EBSYSDbContext>(options =>
        {              
            options.AddDefaultRepositories(includeAllEntities: true);
        });

我这样配置,单元测试时,数据访问始终跑到 sqlite.

allanzhong的主页 allanzhong | 初学一级 | 园豆:199
提问于:2021-06-20 12:40
< >
分享
所有回答(1)
0

//注册数据库的服务
string connectionString = Configuration.GetConnectionString("firstContext");
string connectionString2 = Configuration.GetConnectionString("secondContext");

      services.AddDbContext<firstContext>(options => options.UseMySql(connectionString));
      services.AddDbContext<secondContext>(options => options.UseMySql(connectionString2));
不知道风往哪儿吹 | 园豆:2035 (老鸟四级) | 2021-06-21 17:18

谢谢您的回复,这样还是不行,在单元测试环境下还是跑到sqllite

支持(0) 反对(0) allanzhong | 园豆:199 (初学一级) | 2021-06-25 18:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册