using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using MiGu.DB.Kernel.Context;

namespace MiGu.DB.Kernel.Design;

/// <summary>
/// design-time 工厂（dotnet ef migrations add）。指定 MigrationsAssembly，与运行时 SqliteProviderSetup 一致。
/// </summary>
public sealed class MiGuDbContextFactory : IDesignTimeDbContextFactory<MiGuDbContext>
{
    public MiGuDbContext CreateDbContext(string[] args)
    {
        var options = new DbContextOptionsBuilder<MiGuDbContext>()
            .UseSqlite("Data Source=platform.db", o =>
                o.MigrationsAssembly(typeof(MiGuDbContext).Assembly.GetName().Name))
            .Options;
        return new MiGuDbContext(options);
    }
}
