public static void Initialize(IServiceProvider serviceProvider) { using (var context = new GlDbContext(serviceProvider.GetRequiredService <DbContextOptions <GlDbContext> >())) { context.Database.EnsureCreated(); // Seed data when first run if (!context.Airports.Any()) { new DataSeeder().SeedData(context); } } }
public static void ClassInitialize(TestContext context) { var options = new DbContextOptionsBuilder <GlDbContext>() .UseInMemoryDatabase(databaseName: "Test_database") .Options; var dbContext = new GlDbContext(options); dbContext.Database.EnsureCreated(); // Seed data when first run if (!dbContext.Airports.Any()) { new DataSeeder().SeedData(dbContext); } _routeService = new RouteService(dbContext); }
public RouteService(GlDbContext dbContext) { _dbContext = dbContext; }