Learn how to modify the local schema and push those modifications to the Azure database.
- [Instructor] We'd like to add a review for each of the books in our detail. And we're going to think of that as Stars, one to five stars. So, we need to modify our model. Let's go back to the detailed model class. And here, we're going to add a new property. And we'll say, "public int Stars" (typing) And that modifies property. And remember we're doing code first.
So, that is going to modify the schema of the database. Let's start by rebuilding this solution, which we can see in the output window. And with that having succeeded, we're now ready to modify the schema on Azure. To do that, we'll go back to the Package Manager Console. Let's clear the window with the Clear command. And we're going to add the migration for that property. So we'll say, "add migration, add property".
It's going to look, and find the property that will update the migration, so we'll say, "update database". That's going to update it with the new schema. And it ran the Seed method, but the Seed method currently does not have any Stars. So, if we go back to the details, and Refresh, and then View Data, no Stars are showing because we have not modified our details to incorporate the Stars.
To fix that, we're going to go back to the Package Manager Console. Once again, let's say, "clear." And this time, we're going to say, "update database". Let's close the View Data page. Come back to it. Open it up. And now we do have the Stars. Notice that they're zero, so let's go back to our configuration where we have the Seed, and we will give Ulysses five Stars, as it's my favorite book of all time.
Les Miserables is a close second. But just for the variety, we'll give it four stars. Although, frankly it's a five-star book. Let's rebuild. And the output window will show that that has succeeded. We'll push the up arrow for updating the database, and the Seed method, let's close the Detail window. And we'll click on Details, View Data, and now the stars show with the correct values.
- 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