我进行了迁移(使用Fluent Migrator),只是注意到我在外键上的表名上输入了错误。
我该如何解决?我应该进行新的迁移吗?
public class AdditionalCosts : Migration
{
public override void Up()
{
Create.Table("AdditionalCosts").WithColumn("ID").AsInt32().PrimaryKey().Identity()
.WithColumn("DocTypeID").AsInt32().NotNullable()
.WithColumn("Cost").AsInt32().NotNullable()
.WithColumn("CreatedAt").AsDateTime().Nullable().WithDefault(SystemMethods.CurrentDateTime)
.WithColumn("AddedBy").AsString().Nullable()
.WithColumn("ModifiedAt").AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentDateTime)
Create.ForeignKey()
.FromTable("AdditionalCosts").ForeignColumn("DocTypeID")
.ToTable("Documents").PrimaryColumn("ID");
}
public override void Down()
{
Delete.Table("AdditionalFees");
}
}
外键应为(不同的ToTable
):
Create.ForeignKey()
.FromTable("AdditionalCosts").ForeignColumn("DocTypeID")
.ToTable("DocumentTypes").PrimaryColumn("ID");
答案 0 :(得分:0)
通过@Liam,我可以通过运行以下命令回滚到上一个迁移:
dotnet fm rollback -c ';Persist Security Info=True;User ID=test;Password=test; Initial Catalog=test;Data Source=.\SQLEXPRESS' -p SqlServer -a ./Project.Data/bin/Debug/netcoreapp2.2/Project.Data.dll to 20190123125705 --migration version