0
votes

I keep getting this error when I try to do an update-database command in the package manager console:

ClientConnectionId:00000000-0000-0000-0000-000000000000 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: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid. )

My connection string is:

<connectionStrings>
    <add name="BookServiceContext" connectionString="Data Source=(localdb)\\v11.0; Initial Catalog=BookServiceContext-20150228232739; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>

I can connect via SSMS 2014 and I can see (localdb)\MSSQLLocalDB and (localdb)\ProjectsV12 in the SQL Server Object Explorer.

EDIT

Even when a part of connection string is changed to: AttachDbFilename=|DataDirectory|\BookServiceContext-20150228232739.mdf"

It still pulls the same error.

2

2 Answers

0
votes

There is a backslash missing in you connection string:

instead of

AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf"

it should be

AttachDbFilename=|DataDirectory|\BookServiceContext-20150228232739.mdf"

Refer to Creating a Connection String and Working with SQL Server LocalDB

Update

It turns out that after a \ wasn't missing but there are too many of them. I was able to reproduce the error by adding another \ to

Data Source=(localdb)\\v11.0

this means your Data Source should be:

Data Source=(localdb)\v11.0

with only one \

0
votes

Kindly check your connection string

Data Source=(localdb)\ProjectsV13;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False