0
讓說我有定義的隨機碼第一遷移類:實體框架代碼首先:觸發特定遷移
public partial class t2 : DbMigration
{
public override void Up()
{
RenameTable(name: "dbo.EntityC", newName: "EntityCs");
DropTable("dbo.EntityA");
DropTable("dbo.EntityB");
}
public override void Down()
{
CreateTable(
"dbo.EntityB",
c => new
{
Id = c.Int(nullable: false, identity: true),
StringOtherProperty = c.String(),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.EntityA",
c => new
{
Id = c.Int(nullable: false, identity: true),
StringProperty = c.String(),
})
.PrimaryKey(t => t.Id);
RenameTable(name: "dbo.EntityCs", newName: "EntityC");
}
}
我如何執行它,不管當前的數據模型。 我可以通過代碼或PowerShell強制執行此遷移嗎?