remove ensure mirgration

and scope.serviceProvider.getService
This commit is contained in:
2026-05-10 21:49:38 +10:00
parent 4c19ec3e6a
commit 936094a4bf
+1 -19
View File
@@ -103,19 +103,7 @@ using (var scope = app.Services.CreateScope())
var db = context.Database; var db = context.Database;
if (db != null) if (db != null)
{ {
try var staff = scope.ServiceProvider.GetService<Seed>();
{
using var cts = new CancellationTokenSource();
CancellationToken cancellationToken = cts.Token;
await db.MigrateAsync(cancellationToken);
db.EnsureCreated();
}
catch
{
//continue
}
var staff = context.GetService<Seed>();
int id = staff.InsertOneUser(); int id = staff.InsertOneUser();
if (id < 0) if (id < 0)
{ {
@@ -131,23 +119,17 @@ using (var scope = app.Services.CreateScope())
{ {
//continue //continue
} }
} }
id = staff.InsertOneUser(); id = staff.InsertOneUser();
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e.ToString()); Console.WriteLine(e.ToString());
} }
} }
app.UseMiddleware<JwtMiddleware>(); app.UseMiddleware<JwtMiddleware>();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())// //if (app.Environment.IsDevelopment())//