diff --git a/API/FamilyTreeAPI/Program.cs b/API/FamilyTreeAPI/Program.cs index 117d54d..2c1cbfd 100644 --- a/API/FamilyTreeAPI/Program.cs +++ b/API/FamilyTreeAPI/Program.cs @@ -102,10 +102,19 @@ using (var scope = app.Services.CreateScope()) var context = scope.ServiceProvider.GetRequiredService(); var db = context.Database; if (db != null) - { - - db.Migrate(); - db.EnsureCreated(); + { + try + { + using var cts = new CancellationTokenSource(); + CancellationToken cancellationToken = cts.Token; + await db.MigrateAsync(cancellationToken); + db.EnsureCreated(); + } + catch + { + //continue + } + var staff = context.GetService(); int id = staff.InsertOneUser(); if (id < 0) @@ -114,7 +123,15 @@ using (var scope = app.Services.CreateScope()) if (databaseCreator != null) { //if (!databaseCreator.Exists()) - databaseCreator.CreateTables(); + try + { + databaseCreator.CreateTables(); + } + catch + { + //continue + } + } id = staff.InsertOneUser(); }