From 59af920479b04fc51aa2fdf7b1b74a039b42a1f8 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 1 Mar 2026 08:09:49 -0500 Subject: [PATCH] admin fixes --- Server/src/SOR.Admin/Program.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Server/src/SOR.Admin/Program.cs b/Server/src/SOR.Admin/Program.cs index a3eeb4c..e38f75f 100644 --- a/Server/src/SOR.Admin/Program.cs +++ b/Server/src/SOR.Admin/Program.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; @@ -141,11 +142,26 @@ app.MapRazorPages(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); +// ── Apply pending migrations ─────────────────────────────────────────────── +await MigrateAllAsync(app); + // ── Seed roles and initial SuperAdmin ───────────────────────────────────── await SeedAsync(app); app.Run(); +static async Task MigrateAllAsync(WebApplication app) +{ + using var scope = app.Services.CreateScope(); + var sp = scope.ServiceProvider; + await sp.GetRequiredService().Database.MigrateAsync(); + await sp.GetRequiredService().Database.MigrateAsync(); + await sp.GetRequiredService().Database.MigrateAsync(); + await sp.GetRequiredService().Database.MigrateAsync(); + await sp.GetRequiredService().Database.MigrateAsync(); + await sp.GetRequiredService().Database.MigrateAsync(); +} + static async Task SeedAsync(WebApplication app) { using var scope = app.Services.CreateScope();