If you created a ASP.NET MVC4 app using EF5 code first model, and you want to deploy the app onto Windows Azure, basically there are 2 steps you need to follow:
First, enable code first migration so server side knows how to re-create the database. You can achieve this in Package Management Console by executing “enable-migrations”. If succeeded you will see a new folder name Migrations created in the project file root (see screenshot), click here for more details of code first migrations.
Then create a web site on Azure server and remember to create a database at the same time by following the online guide. Once website created you can get the publish profile which contains the database connection string so later when you use the publish profile to deploy your website those values can be used to replace your LocalDB connection string value (see screenshot below), and remember tick the Execute Code First Migrations option before click Next.
No comments:
Post a Comment