实体框架5代码优先降级迁移

时间:2014-09-17 11:09:10

标签: c# entity-framework ef-code-first entity-framework-5

我们将Entity Framework 5与Code First一起使用。 我们编写了一个IDatabaseInitializer,用于将数据库降级到以前的版本。

因此,我们希望在上一次降级步骤中撤消初始数据库设置步骤。 即数据库与首次安装之前一样。 如何使用Entity Framework Migrations执行此操作?只是放弃架构是 不可能,因为架构不是空的。

http://msdn.microsoft.com/en-us/library/hh829363(v=vs.113).aspx写道:

public void Update()
Updates the target database to the latest migration.

public override void Update(string targetMigration)
targetMigrationType: System.String / The migration to upgrade/downgrade to.

我的问题是,我没有删除第一步的targetMigration名称。我在努力 用“0”,但它没有用。 当我使用Update()时,我的数据库设置为我不想要的最新版本。怎么表演?

1 个答案:

答案 0 :(得分:0)

DbMigrator.InitialDatabase

与" 0"相同。不知道,为什么它最初不能用" 0"。