|
@@ -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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|