ef core自定义默认的迁移表的名称
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Long.EntityFrameworkCore;
class MyDesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args)
{
DbContextOptionsBuilder<ApplicationDbContext> builder = new();
string connStr =
"Data Source=localhost;Initial Catalog=test31;User ID=sa;Password=xxxxxx;Trust Server Certificate=True";
//👇 :默认迁移表名称 👇架构
builder.UseSqlServer(connStr,x=>x.MigrationsHistoryTable("__EFMigrationsHistory_Book","dbo"));
return new ApplicationDbContext(builder.Options);
}
}