jellyfin/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs

21 lines
733 B
C#
Raw Normal View History

2020-05-03 00:32:22 +02:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Jellyfin.Server.Implementations.Migrations
{
/// <summary>
2023-01-16 18:14:44 +01:00
/// The design time factory for <see cref="JellyfinDbContext"/>.
2020-05-03 00:32:22 +02:00
/// This is only used for the creation of migrations and not during runtime.
/// </summary>
2023-01-16 18:14:44 +01:00
internal class DesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory<JellyfinDbContext>
2020-05-03 00:32:22 +02:00
{
2023-01-16 18:14:44 +01:00
public JellyfinDbContext CreateDbContext(string[] args)
2020-05-03 00:32:22 +02:00
{
2023-01-16 18:14:44 +01:00
var optionsBuilder = new DbContextOptionsBuilder<JellyfinDbContext>();
2020-05-15 18:51:18 +02:00
optionsBuilder.UseSqlite("Data Source=jellyfin.db");
2020-05-03 00:32:22 +02:00
2023-01-16 18:14:44 +01:00
return new JellyfinDbContext(optionsBuilder.Options);
2020-05-03 00:32:22 +02:00
}
}
}