using System; using System.IO; using MediaBrowser.Common.Configuration; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace Jellyfin.Server.Implementations.Extensions; /// /// Extensions for the interface. /// public static class ServiceCollectionExtensions { /// /// Adds the interface to the service collection with second level caching enabled. /// /// An instance of the interface. /// The updated service collection. public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection) { serviceCollection.AddPooledDbContextFactory((serviceProvider, opt) => { var applicationPaths = serviceProvider.GetRequiredService(); opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}"); }); return serviceCollection; } }