//public static void Main(string[] args) //{ // CreateWebHostBuilder(args).Build().Run(); //} //public static IWebHostBuilder CreateWebHostBuilder(string[] args) => // WebHost.CreateDefaultBuilder(args) // .UseStartup<Startup>(); public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) // нужно для получения DbContext { var services = scope.ServiceProvider; try { WebStoreContext context = services.GetRequiredService <WebStoreContext>(); DbInit.Initialize(context); DbInit.InitializeUser(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "Oops... Something went wrong at DB initializing..."); } } host.Run(); }