I follow the this tutorial step 1- 5 and check it locally and its working great http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started Now I convert the solution to azure and publish it and I was able to see the Asp page but when I navigate to the movies (in the URL) I got error ,i guess that this is related to the data base ,in the app data folder I have the local DB there is a way to convert it azure DB or storage that I will able to update the data from azure url and not from local?
1 Answer
The best way to do this is to create an Azure SQL Database. Note, in the tutorial, you can probably stop at Step 4, since EF Code First will take care of generating the schema.
Then you'll want to set up Web.config transforms to your Web.Debug.config and Web.Release.config files, and Visual Studio will automatically change your connection string when you deploy.
Inside your Web.config, find your connection string:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=DatabaseName;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
(note your actual connection string might be different, if using SQL Express or something)
Then add the following to Web.Debug.config and Web.Release.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Server={the connection string from the Azure portal}" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
Make sure the connection string name is the same as in Web.config, so it knows which one to replace.
Now when you run the project locally, it'll connect to your local database. When you deploy to Azure, it'll connect to the Azure SQL Database.