public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (IServiceScope scope = host.Services.CreateScope()) { try { ITimeTrackerDbContext abstractContext = scope.ServiceProvider.GetService <ITimeTrackerDbContext>(); TimeTrackerDbContext context = (TimeTrackerDbContext)abstractContext; context.Database.Migrate(); IWebHostEnvironment environment = scope.ServiceProvider.GetService <IWebHostEnvironment>(); if (environment.IsDevelopment()) { TimeTrackerDbInitializer.Seed(context); } } catch (Exception e) { Console.WriteLine(e); } } host.Run(); }
public static void InitializeDbForTest(TimeTrackerDbContext context) { TimeTrackerDbInitializer.Seed(context); }