Update web application in azure with code and database changes from your local machine
In this video we will discuss how to push changes (i.e both code and database changes) and update web application that is already deployed in azure. To migrate local database changes to azure SQL database we use entity framework code first migrations.
Current state of the web application
If you have been following along this course. We have a web application that displays inspirational quotes as shown below.
These quotes come from the following Quotes
table.
At the moment, this app is already deployed in azure. We discussed how to do this in our previous videos in this series.
Changes being made on the local machine
Introduce Author
column in the Quotes
table and populate the values as shown below.
On the web page, along with the quote, the author name also must be displayed as shown below.
Changes on local development machine
Go to Package Manager Console (View - Other Windows - Package Manager Console) in Visual Studo and enable entity framework migrations using the following command.
Add Author
property to the Quote
class
Add a new migration using the following command. This creates the required code to add Author
column to Quotes
table.
In the Migrations
folder, you will see a new file created (file name ends with Add_Quote_Author.cs). Modify this file to include values for the newly added author column as shown below.
Execute the following command to apply this migration to the database
Modify default.aspx
to display Author
name as shown below.
Run the app locally and you should see the author name along with the quote itself.
No comments:
Post a Comment