I assume you’ve created a project, code first model to work with, and installed the latest version of Entity Framework NuGet package.
After you’ve built an Initial Model and Database, you need to enable migrations: run the
command in Package Manager Console.
Next you’re going to become familiar with two primary commands: Add-Migration and Update-Database. Example:
Add-Migration AddFieldToModel Update-Database
Both commands are run in Package Manager Console.
So far we’ve always upgraded to the latest migration, but there may be times when you want to upgrade/downgrade to a specific migration. Imagine you’ve created a Migration called DeleteFieldFromModel and you want to migrate it. You can use the -TargetMigration switch to downgrade to this migration. Example:
If you want to roll all the way back to an empty database then you can use the
When you deploy a Web site, you often want some settings in the deployed application’s Web.config file to be different from the development Web.config file. For example, you might want to disable debug options and change connection strings so that they point to different databases. This topic explains how to set up a Web.config transform file that is applied automatically during deployment in order to make changes to the deployed versions of Web.config files.