Search code examples
c#asp.net-mvcvisual-studiodatabase-migrationentity-framework-migrations

How apply migrations to the production server using Visual Studio 2015?


Apply code first migrations is easy working locally. Just type "update-database" into Package Manager Console to update the local database.

However, what about to update the remote database? How can I apply migrations to it?


Solution

  • You can change the connection string in your web.config file to point to the remote sql server, and then run the same update-database command.

    Alternatively, you can generate the sql script with the -Script flag when running the Update-Database command. (Update-Database -ProjectName NameOfProject -Script) This will generate the script needed to run on the remote database