put in try and catch just continue

This commit is contained in:
2026-04-04 23:40:26 +11:00
parent 817eee7d3e
commit d57751eefa
+22 -5
View File
@@ -102,10 +102,19 @@ using (var scope = app.Services.CreateScope())
var context = scope.ServiceProvider.GetRequiredService<FamilyTreeDBContext>(); var context = scope.ServiceProvider.GetRequiredService<FamilyTreeDBContext>();
var db = context.Database; var db = context.Database;
if (db != null) if (db != null)
{ {
try
db.Migrate(); {
db.EnsureCreated(); using var cts = new CancellationTokenSource();
CancellationToken cancellationToken = cts.Token;
await db.MigrateAsync(cancellationToken);
db.EnsureCreated();
}
catch
{
//continue
}
var staff = context.GetService<Seed>(); var staff = context.GetService<Seed>();
int id = staff.InsertOneUser(); int id = staff.InsertOneUser();
if (id < 0) if (id < 0)
@@ -114,7 +123,15 @@ using (var scope = app.Services.CreateScope())
if (databaseCreator != null) if (databaseCreator != null)
{ {
//if (!databaseCreator.Exists()) //if (!databaseCreator.Exists())
databaseCreator.CreateTables(); try
{
databaseCreator.CreateTables();
}
catch
{
//continue
}
} }
id = staff.InsertOneUser(); id = staff.InsertOneUser();
} }