Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of Update-Database in EF Migrations when deployed in Azure

Context: I have my ASP.NET MVC4 solution deployed in Azure.
My MSSQL Server Database is also there, in Azure.

I currently deploy this way:

  1. In web.config I change the connection string from local database (sdf) to azure database (connectionString="Server=tcp:.....database.windows.net, ...")

  2. Right click on project name (visual studio), and then "Publish"

So, my question is:
How do I use the Update-database command in the Package Manager Console?

Is it this way?

  1. Same step #1 from above
  2. Run Update-Database

I want to be sure about this. Also, I guess I should add the firewall IP exception from Azure before running step #2

like image 500
sports Avatar asked Jun 11 '13 16:06

sports


1 Answers

Yes, you are right. At least that is how it worked for me:

  • Enable a firewall rule for your current IP Address in Azure
  • Update your web.config connection string according with your Azure Database conneciton string.
  • Run Update-Database in your Package Manager Console

On the other hand, due to your situation ("I want to be sure about this") i recommend to duplicate the database in Azure and test this steps with this backup.

Hope it helps.

EDIT due to comment:

Check this out: Triggering EF migration at application startup by code

like image 153
Vic Avatar answered Sep 20 '22 16:09

Vic