0

I've Create MVC5 APP with Local DB like the following link(step 1 to 5) http://www.asp.net/mvc/tutorials/mvc-5/database-first-development/creating-the-web-application And the application is running as expected and now I need to change the DB from the sql Lite to azure DB ,I have created the same DB in azure (same data structure)and now what I want that the application use this DB ,There is simple way to do that ?

Im using VS2013 for web.

4
  • Have you followed the tutorial for this? If you want to deploy your website on azure as well, there's a step-by-step documentation for this Commented Mar 23, 2014 at 12:22
  • 1
    @serv-can you provide this docu please,Im stuck :(? Commented Mar 23, 2014 at 16:01
  • windowsazure.com/en-us/documentation/articles/… there you go Commented Mar 23, 2014 at 16:06
  • @Serv- Thanks I already see that...the adding class but I didnt see where you actually connect it to the azure DB. in addtion there is no way to do that by add ADO.net entity frame work and generate from the DB that I already created in azure? Commented Mar 23, 2014 at 16:12

1 Answer 1

2

Just change the "source" and "initial catalog" parameters of the connection string in the web.config file. Also, SQL Azure doesn't work with integrated security so you need to remove the "integrated security" parameter from the connection string and add the parameters "User ID" and "Password" with the credential of a user that you created in SQL Azure.

  • Open Visual Studio In Solution Explorer
  • find the file web.config
  • Look for the section connectionStrings

You should find something similar to:

<add name="testEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\test.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

You need to:

  • Replace (LocalDB)\v11.0 with the name of your server
  • Remove "attachdbfilename=|DataDirectory|\test.mdf;integrated security=True;"
  • Add "Initial catalog=[name of your database in SQL Azure];user id=[name of your user id on SQL Azure];password=[your password]
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Andrea, voted up,Im very new to this topic e.g. where the source is locketed etc ,can you please provide step by step example
I put some step-by-step example in my previous reply

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.