Learn how to update the Azure database with the schema from the models on the MVC application.
- [Instructor] Now that we have our seed data in place we want to get that up to our Azure database. So we're going to come down to the Package Manager Console and say update-database and then we'll add the verbose flag. And it's going to fail and the reason it fails, you can see, is on the IP address. Azure is configured to only accept this kind of command from within Azure unless you tell it otherwise.
So let's go back to Azure and add our database. In the menu on top, you see Set server firewall. We'll click on that, and what this is telling us is that there are no special rules, but it does know our client IP address. And up here in the menu, it says Add client IP. Let's go ahead and do that and that adds the client IP address as a legitimate address that should be able to access this database. Don't forget to hit Save.
That updates the database, and you could see it successfully updated the firewall. Let's go back to Visual Studio and try that command again. And we'll push the Up Arrow to bring it up, fire that off, and it runs the seed method which is just what we wanted. Let's come up to our View menu, choose the SQL Server Object Explorer. Here's our SQL Servers that it knows about. We'll right click and say Add a SQL Server, and up comes the Browse window for SQL Server.
We'll go to Azure, sure enough there's our database. It already knows my user name. I only have to put in my password. And this is the password that I created when I created the database and that's also in the web config. So let's connect to that database, and we'll open it up. And under Databases, we're going to find our database, open that up. And under Tables, we find our Orders table and our Details table.
If I come to the Orders table, right click and say View Data it bring up the data in that table, and notice OrderId one is first order coming right out of our seed data. Let's check the details, View Data, and sure enough there are our two details, one and two, both associated with OrderID one, and each with its own description. So we have now updated the database on Azure.
And as you can see, this is the Azure database talking to Azure.
- Creating an MVC web app
- Publishing an MVC app to Azure
- Creating a SQL database on Azure
- Enabling migrations
- Updating an Azure database
- Changing the schema
- Exploring various types of Blob storage
- Creating Blob storage accounts in Azure
- Examining Azure statistics for monitoring Blob storage