forked from SoDOff-Project/sodoff
apply pending migrations each start
This commit is contained in:
parent
625af3af7d
commit
aee7f7ff15
@ -7,6 +7,7 @@ using sodoff.Services;
|
||||
using sodoff.Utils;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -64,6 +65,13 @@ using var scope = app.Services.CreateScope();
|
||||
|
||||
scope.ServiceProvider.GetRequiredService<DBContext>().Database.EnsureCreated();
|
||||
|
||||
// ensure any new migrations are applied
|
||||
var migrations = scope.ServiceProvider.GetRequiredService<DBContext>().Database.GetPendingMigrations();
|
||||
|
||||
if (migrations != null)
|
||||
// apply them
|
||||
await scope.ServiceProvider.GetRequiredService<DBContext>().Database.MigrateAsync();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
if (assetServer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user