问题
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:
In web.config I change the connection string from local database (sdf) to azure database (
connectionString="Server=tcp:.....database.windows.net, ..."
)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?
- Same step #1 from above
- 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
回答1:
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
来源:https://stackoverflow.com/questions/17048910/usage-of-update-database-in-ef-migrations-when-deployed-in-azure