What is the use of Migrations in MVC

Posted by Swappy_Gaj under ASP.NET MVC on 1/20/2015 | Points: 10 | Views : 1375 | Status : [Member] | Replies : 1
Exactly what is the use of Migrations in MVC
When it is useful


Posted by: kgovindarao523-21772 on: 1/21/2015 [Member] [MVP] Bronze | Points: 25


When you develop a new application, your data model changes frequently, and each time the model changes, it gets out of sync with the database.
You have configured the Entity Framework to automatically drop and re-create the database each time you change the data model.
When you add, remove, or change entity classes or change your DbContext class, the next time you run the application it automatically deletes your existing database, creates a new one that matches the model, and seeds it with test data.
This method of keeping the database in sync with the data model works well until you deploy the application to production.
When the application is running in production it is usually storing data that you want to keep, and you don't want to lose everything each time you make a change such as adding a new column.
The Code First Migrations feature solves this problem by enabling Code First to update the database schema which allow you to update existing database with new model classes changes and your existing database remains same with your database records.

Thank you,

Swappy_Gaj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response