Updated table migration logic

This commit is contained in:
2026-03-18 07:04:39 +00:00
parent 251e3c5821
commit 44333e69e7

View File

@@ -51,8 +51,19 @@ var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
db.Database.Migrate();
try
{
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
if (db.Database.GetPendingMigrations().Any())
{
db.Database.Migrate();
}
}
catch (Exception ex)
{
Console.WriteLine($"Database Migration skipped or failed: {ex.Message}");
}
}
app.UseDefaultFiles();