In this post we will be discussing about solving Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration in in ASP.NET MVC 5 when used with Entity Framework.
Lets say you have created a model to the existing database and then you want to update the database to reflect the new changes. When you type Update-Database you will get the below error.
Code-First Migration in Entity Framework has two important commands and they are :
1. Add-Migration : It will scaffold the next migration for the changes you have made to your domain classes.
2. Update-Database: It will apply pending changes to the database based on latest scaffolding colde file you have created using 'Add-Migration' command.
To solve this error we need to scaffold the next migration for the changes using the command Add-Migration as shown below :
Next we will again run the command Update-Database which will update the database as per your new models.
Please Like and Share the Blog, if you find it interesting and helpful.
Lets say you have created a model to the existing database and then you want to update the database to reflect the new changes. When you type Update-Database you will get the below error.
Code-First Migration in Entity Framework has two important commands and they are :
1. Add-Migration : It will scaffold the next migration for the changes you have made to your domain classes.
2. Update-Database: It will apply pending changes to the database based on latest scaffolding colde file you have created using 'Add-Migration' command.
To solve this error we need to scaffold the next migration for the changes using the command Add-Migration as shown below :
Next we will again run the command Update-Database which will update the database as per your new models.
Please Like and Share the Blog, if you find it interesting and helpful.
Related articles
- How to Integrate CKEditor in Asp Net Web Application
- Integrate Colorbox in Asp Net Web Application
- 10 Interview Questions on Nodejs
- Print Screen in Asp Net Web Application
- Handle Mouse Events in jQuery
- Recently Launched Visualize.js : Javascript API framework
- 5 Tips for Beginner Nodejs Developers
- How to receive data from the Querystring in Nodejs
- Macros for Visual Studio 2012 and 2013
- Raddish : New Node.js framework
No comments:
Post a Comment