public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { DatabaseInitialization.InitializeDatabase(services); var commandBus = services.GetRequiredService <ICommandBus>(); if (commandBus != null) { commandBus.ExecuteAsync(new CacheSettingCommand()).Wait(); } } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred Initializing the DB."); } } host.Run(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); IDatabaseInitializer <DatabaseContext> init = new DatabaseInitialization(); Database.SetInitializer(init); init.InitializeDatabase(new DatabaseContext()); Dal d = new Dal(); d.InitializeDatabase(); }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { DatabaseInitialization.InitializeDatabase(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred Initializing the DB."); } } host.Run(); }