using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Jellyfin.Server.Implementations
{
    /// 
    /// Factory class for generating new  instances.
    /// 
    public class JellyfinDbProvider
    {
        private readonly IServiceProvider _serviceProvider;
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The application's service provider.
        public JellyfinDbProvider(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
            serviceProvider.GetRequiredService().Database.Migrate();
        }
        /// 
        /// Creates a new  context.
        /// 
        /// The newly created context.
        public JellyfinDb CreateContext()
        {
            return _serviceProvider.GetRequiredService();
        }
    }
}