Don't dispose database context for server processes

net8.0
Pat Hartl 2023-11-17 12:57:23 -06:00
parent 6b005eb384
commit 09d23bcb78
1 changed files with 7 additions and 8 deletions

View File

@ -228,8 +228,8 @@ namespace LANCommander
// Migrate
Logger.Debug("Migrating database if required");
await using var scope = app.Services.CreateAsyncScope();
using (var db = scope.ServiceProvider.GetService<DatabaseContext>())
{
using var db = scope.ServiceProvider.GetService<DatabaseContext>();
if ((await db.Database.GetPendingMigrationsAsync()).Any())
{
var dataSource = new SqliteConnectionStringBuilder(settings.DatabaseConnectionString).DataSource;
@ -239,7 +239,6 @@ namespace LANCommander
await db.Database.MigrateAsync();
}
}
// Autostart any server processes
Logger.Debug("Autostarting Servers");