I have installed SQL Server 2014 localdb and SQL Server Management Studio. I am trying to connect to the localdb
using a WPF application developed in Visual Studio.
Here is the connection string that I am using
<connectionStrings>
<add name="ReservationContextString"
connectionString="Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ReservationDB;AttachDbFilename=|DataDirectory|\\ReservationDB.mdf"
providerName="System.Data.SqlClient" />
</connectionStrings>
When I run the application I get the following exception
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I am not sure why the application could not connect to localdb
Note: I am able to use the SQL Server Management Studio to connect to localdb
using (localdb)\MSSQLLocalDB
as Server Name. So, localdb seems to be installed properly.
Initial Catalog=ReservationDB
) in your LocalDB instance, as well as (2) defining a.mdf
file to attach (AttachDbFilename=|DataDirectory|\\ReservationDB.mdf
) - you can do either of the two, but I'm not sure what happens if you do both things at once. Try one OR the other - does that work? – marc_supdate-database
et al) see this answer. – Marc.2377