public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <corporateContext>(); SampleFiles.Initialize(context); SampleDepartment.Initialize(context); SampleSpecialities.Initialize(context); SampleStatuses.Initialize(context); SamplePriority.Initialize(context); SampleDifficulties.Initialize(context); SampleWorkers.Initialize(context); SampleTasks.Initialize(context); SampleProducts.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB."); } } host.Run(); }