diff options
| author | JPVenson <github@jpb.email> | 2025-05-04 17:27:03 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 08:27:03 -0600 |
| commit | 4096c973c623a72525843d5fe278d1f36fbbc58a (patch) | |
| tree | 8f1ea79f792baf0d9f2724c145a5642e4d81381b | |
| parent | ce0a6b2df81b63f2f894ae30a343f018fec7c52c (diff) | |
fix #14034 Readd Context provider on Initialise (#14040)
| -rw-r--r-- | Jellyfin.Server/Program.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 12903544d..745f92420 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -23,6 +23,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -175,6 +176,9 @@ namespace Jellyfin.Server // Re-use the host service provider in the app host since ASP.NET doesn't allow a custom service collection. appHost.ServiceProvider = _jellyfinHost.Services; + + PrepareDatabaseProvider(appHost.ServiceProvider); + await ApplyCoreMigrationsAsync(appHost.ServiceProvider, Migrations.Stages.JellyfinMigrationStageTypes.CoreInitialisaition).ConfigureAwait(false); await appHost.InitializeServices(startupConfig).ConfigureAwait(false); @@ -248,6 +252,9 @@ namespace Jellyfin.Server .AddSingleton<IApplicationPaths>(appPaths) .AddSingleton<ServerApplicationPaths>(appPaths); var startupService = migrationStartupServiceProvider.BuildServiceProvider(); + + PrepareDatabaseProvider(startupService); + var jellyfinMigrationService = ActivatorUtilities.CreateInstance<JellyfinMigrationService>(startupService); await jellyfinMigrationService.CheckFirstTimeRunOrMigration(appPaths).ConfigureAwait(false); await jellyfinMigrationService.MigrateStepAsync(Migrations.Stages.JellyfinMigrationStageTypes.PreInitialisation, startupService).ConfigureAwait(false); @@ -302,5 +309,12 @@ namespace Jellyfin.Server .AddEnvironmentVariables("JELLYFIN_") .AddInMemoryCollection(commandLineOpts.ConvertToConfig()); } + + private static void PrepareDatabaseProvider(IServiceProvider services) + { + var factory = services.GetRequiredService<IDbContextFactory<JellyfinDbContext>>(); + var provider = services.GetRequiredService<IJellyfinDatabaseProvider>(); + provider.DbContextFactory = factory; + } } } |
