示例#1
0
文件: BaseTest.cs 项目: bngapiusr/CUM
        private CumContext GetInMemoryDBContext()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .BuildServiceProvider();

            var builder = new DbContextOptionsBuilder <CumContext>();
            var options = builder.UseInMemoryDatabase("test").UseInternalServiceProvider(serviceProvider).Options;

            CumContext dbContext = new CumContext(options);

            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();
            return(dbContext);
        }
示例#2
0
文件: BaseTest.cs 项目: bngapiusr/CUM
 public BaseTest(CumContext cxt = null)
 {
     this.cxt = cxt ?? GetInMemoryDBContext();
 }