DesignTimeJellyfinDbFactory.cs 1000 B

12345678910111213141516171819202122232425
  1. using Jellyfin.Database.Providers.SqLite;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Design;
  4. using Microsoft.Extensions.Logging.Abstractions;
  5. namespace Jellyfin.Server.Implementations.Migrations
  6. {
  7. /// <summary>
  8. /// The design time factory for <see cref="JellyfinDbContext"/>.
  9. /// This is only used for the creation of migrations and not during runtime.
  10. /// </summary>
  11. internal sealed class DesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory<JellyfinDbContext>
  12. {
  13. public JellyfinDbContext CreateDbContext(string[] args)
  14. {
  15. var optionsBuilder = new DbContextOptionsBuilder<JellyfinDbContext>();
  16. optionsBuilder.UseSqlite("Data Source=jellyfin.db");
  17. return new JellyfinDbContext(
  18. optionsBuilder.Options,
  19. NullLogger<JellyfinDbContext>.Instance,
  20. new SqliteDatabaseProvider(null!, NullLogger<SqliteDatabaseProvider>.Instance));
  21. }
  22. }
  23. }