0

Fairly new to MVC so this probably seems like a fairly newbie question.

I've been developing my application using a SQLExpress instance/LocalDb, I'm now ready to deploy my site to production, so my question is how do I configure my web.config file for this environment?

My database has been created in production, I'm just struggling with establishing the connection strings.

I'm using a host that I think does not support LocalDB (GearHost), but sources seem to suggest this is possible (even though I've not found any decent examples).

My current development connection strings are below.

Thanks

  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MyApp-20160204160648;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MyApp-20160204160648.mdf" />
    <add name="MyEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MyPC\SQLEXPRESS;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
2
  • stackoverflow.com/questions/1339944/… Commented Jun 30, 2016 at 8:36
  • Not sure this answers the question. I have it working fine in my local/SQLExpress environment. I want to know how I need to adapt my connection string details for a hosted SQL database in a production environment. Commented Jun 30, 2016 at 10:04

1 Answer 1

1

I have a MVC project.I use two conectionString as following

<add name="matematikEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=MYSERVERNAMEONHOST;user id=MYUSERID;password=MYPASSWORD;persistsecurityinfo=True;database=MYDBNAME&quot;" providerName="System.Data.EntityClient" />  
<add name="matematikEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;password=MYPASSWORD;persistsecurityinfo=True;database=MYDBNAME&quot;" providerName="System.Data.EntityClient" />  

When i publish the project,i comment first one and second is active,when i work on my PC i comment second and first one is active.This works.

Sign up to request clarification or add additional context in comments.

Comments

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.