Updated table migration logic
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user