示例#1
0
        public TrafficMonitorContextFactory()
        {
            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new TrafficDetectorProfile());
            });

            Mapper = mapperConfig.CreateMapper();

            var contextOptions = new DbContextOptionsBuilder <TrafficMonitorContext>()
                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                 .EnableSensitiveDataLogging()
                                 .Options;

            EnsureCreation(contextOptions);
            ContextInstance = new TestTrafficMonitorContext(contextOptions);
        }
示例#2
0
 private void EnsureCreation(DbContextOptions <TrafficMonitorContext> contextOptions)
 {
     using var context = new TestTrafficMonitorContext(contextOptions);
     context.Database.EnsureCreated();
 }