我想编写自己的迁移脚本。我的迁移课程:
using Microsoft.EntityFrameworkCore.Migrations;
namespace Foo.Migrations
{
public class FooMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
string script ="<some long script>"
migrationBuilder.Sql(script);
}
}
}
但是当我运行Update-Database时,什么也没发生...
答案 0 :(得分:0)
您需要通过将属性应用于迁移类来指定迁移所属的DbContext和迁移标识符,如下所示:
[DbContext(typeof(MyDbContext))]
[Migration("MyCustomMigration")]
public class FooMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
string script = "<some long script>";
migrationBuilder.Sql(script);
}
}