-1

This is my connection string in local db,

<connectionStrings>
    <add name="liderdatabaseEntities" 
         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=C:\Users\Bertan\Documents\liderdatabase.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

I moved the database to a remote computer (192.168.1.100) What should be the new connectionstring, thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
iceman_bu
  • 11
  • 3
  • Does that other computer also have SQL Server Express `LocalDB` installed? – marc_s Jan 09 '16 at 08:25
  • sql express installed to remote computer and added sa user, password – iceman_bu Jan 09 '16 at 08:34
  • **(1)** ensure that the SQL Server Express on that other computer allows **remote connections** (off by default), and **(2)** adapt your connection string accordingly. – marc_s Jan 09 '16 at 08:34

1 Answers1

1

First things is to ensure that this other computer's SQL Server Express instance allows remote connections - those are OFF by default. See my answer to this other SO question as to how to do that.

Then, you need to adapt the connection string - and I'd strongly recommend putting the database on the server (attach the .mdf file to the SQL Server Express instance) instead of fiddling around with free-floating .mdf files. And also: I'd again strongly recommend never ever to use the sa user - create a separate login/user for your application!

Basically, you need to change the provbider connection string inside your connection string from

provider connection string=&quot;
    data source=(LocalDB)\v11.0;
    attachdbfilename=C:\Users\Bertan\Documents\liderdatabase.mdf;
    integrated security=True;
    connect timeout=30;
    MultipleActiveResultSets=True;
    App=EntityFramework&quot;

to something like

provider connection string=&quot;
    data source=192.168.1.100\SQLEXPRESS;
    database=liderdatabase;
    user id=someuser;
    password=password;
    connect timeout=30;
    MultipleActiveResultSets=True;
    App=EntityFramework&quot;
Community
  • 1
  • 1
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459