Search code examples
ef-code-firstrollbackentity-framework-migrationsdatabase-versioningdatabase-deployment

Code first migrations - how to rollback first migration


Using code first migrations it is trivial to migrate to any given migration by using -TargetMigration [MigrationName].

But how do you rollback to before the first migration? What migration do you target for that? The first migration has a Down() just like the rest and the logic is sound - but how do I get it to execute via a update-database command?


Solution

  • Use this command:

    Update-Database -Target 0