Asp.net database migration, what's the Down method for?
asp.net-mvc-4, database-migration
Solution
Its for when you want to "downgrade" the database to a previous migration state. You use it with the `-TargetMigration` flag of the `Update-Database` command. For example, if you have added the following migrations:
- Initial
- FirstMigration
- SecondMigration (current state)
You can revert the database to the Initial migration state by:
Update-Database -TargetMigration:Initial
In which case the code in the `Down()` methods of the `SecondMigration` and `FirstMigration` classes will run.
Problem
When I add-migration, Up and Down method are generated. and I know when I update database (update-database), it runs the Up method. How about Down method? when it will run, is it for rollback? and, how can I run it?