Migrate the db at startup
This commit is contained in:
parent
4941f3bdef
commit
8bd1653a1e
2 changed files with 8 additions and 3 deletions
|
|
@ -355,7 +355,7 @@ public static class HostingExtensions
|
|||
}
|
||||
|
||||
|
||||
internal static WebApplication ConfigurePipeline(this WebApplication app)
|
||||
internal async static Task<WebApplication> ConfigurePipeline(this WebApplication app)
|
||||
{
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
|
|
@ -365,6 +365,11 @@ public static class HostingExtensions
|
|||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
await db.Database.MigrateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue