diff --git a/Startup.cs b/Startup.cs index e4b5557..515a4f2 100644 --- a/Startup.cs +++ b/Startup.cs @@ -32,8 +32,6 @@ namespace InstructorsListApp { configuration.RootPath = "ClientApp/dist"; }); - - } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -73,6 +71,14 @@ namespace InstructorsListApp spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); } }); + + // initialize database + var serviceScopeFactory = app.ApplicationServices.GetRequiredService(); + using (var serviceScope = serviceScopeFactory.CreateScope()) + { + var dbContext = serviceScope.ServiceProvider.GetService(); + dbContext.Database.EnsureCreated(); + } } } }