diff --git a/src/Program.cs b/src/Program.cs index be2cb13..a9bb892 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -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().Database.EnsureCreated(); +// ensure any new migrations are applied +var migrations = scope.ServiceProvider.GetRequiredService().Database.GetPendingMigrations(); + +if (migrations != null) + // apply them + await scope.ServiceProvider.GetRequiredService().Database.MigrateAsync(); + // Configure the HTTP request pipeline. if (assetServer)