DesignTimeJellyfinDbFactory.cs 822 B

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