How do I rename the last entity framework migration applied on the database

ef-code-first ef-migrations entity-framework entity-framework-6

Question

I have created a code -first entity framework migration and applied to the database, is there a way I can rename this migration ?

1
4
6/23/2017 8:46:58 AM

Accepted Answer

You cannot rename after applying a migration to Database. But you can delete and add another migration with same name or other name.

First reset the migration to last migration

  PM>  update-database -TargetMigration:{lastmigrationname}

If this is the first migration then

  PM>  update-database -TargetMigration:0

Delete the existing migration and relevant files from the source code

Add the migration using the name you want

 PM>  add-migration {MigrationName}

Then update the database with new migration created

 PM> update-database {MigrationName}
10
8/18/2016 6:57:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow