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