Reputation: 61
I tried to find information about this on the web and Stack Overflow, but none of the responses could help me solving my problem.
I'm working with C# and SQL Server. I'm using code from an existing project, which project connects to an SQL Server instance to manage data. This project uses EntityFramework.
Now I want to use a local instance of SQL Server, precisely SQL Server Express, for development purpose. But I can't figure out how to connect to this local instance.
Connecting to the remote SQL Server works perfectly, using this connection string:
<add name="ProjectEntities" connectionString="metadata=res://*/Project.Project.csdl|res://*/Project.Project.ssdl|res://*/Project.Project.msl;provider=System.Data.SqlClient;provider connection string="data source=111.111.111.666\(local), 1433;initial catalog=PROJECT;persist security info=True;user id=user;password=password;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
But if I modify it to use my local instance:
<add name="ProjectEntities" connectionString="metadata=res://*/Project.Project.csdl|res://*/Project.Project.ssdl|res://*/Project.Project.msl;provider=System.Data.SqlClient;provider connection string="data source=.\PROJECT, 1433;initial catalog=PROJECT;persist security info=True;user id=user;password=password;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
it doesn't work.
I tried with putting the source in "MAC\PROJECT" also, it does not change anything. Using the udl file workaround to test connection parameters is totally OK both with "MAC\PROJECT" and ".\PROJECT" and the right credentials.
I can't figure out why my project connect to the database perfectly using the remote server but not the local one. Am I missing something?
Upvotes: 1
Views: 301
Reputation: 61
Right after posting this question I found the answer.... The old connection string gives a port number, which is not needed when connecting to the local instance.
Upvotes: 1