public void DbInitialize(IServiceProvider serviceProvider) { using (var context = new SimDbContext(serviceProvider.GetRequiredService <DbContextOptions <SimDbContext> >())) { if (context.SimEvents.Any()) { return; // DB has been seeded } // Otherwise initialize! } }
public SimEventRepository(SimDbContext db) { DB = db ?? new SimDbContext(); }
public void EnsureCreated(IServiceProvider serviceProvider) { var context = new SimDbContext(serviceProvider.GetRequiredService <DbContextOptions <SimDbContext> >()); context.Database.EnsureCreated(); }
public SimInfoRepository(SimDbContext db) { DB = db ?? new SimDbContext(); }