简体   繁体   中英

Entity Framework 5 Code First Downgrade Migration

We use Entity Framework 5 with Code First. We have written an IDatabaseInitializer for downgrading the database to previous versions.

Consequently, we want in the last downgrade step to undo the initial database setup step. Ie database is as it was before first installation. How can this be performed with Entity Framework Migrations? Just dropping the schema is not possible, because the schema was not empty.

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

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.

My problem is, that I have no targetMigration name to remove the first step. I was trying with "0", but it did not work. When I use Update(), my database is setup to latest version what I don't want. How to perform?

It is

DbMigrator.InitialDatabase

which is the same as "0". Don't know, why it did not work initially with "0".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM