Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist

EDIT: One important detail that I original left out (because I didn't know it was important) is that we were running these sites in full IIS, not from IIS Express.


We're trying to setup local dev environments for Kentico CMS that will add our local machines to our current synchronization chain of Dev --> Staging --> Prod (so we'll wind up with Locals --> Dev --> Staging --> Prod).

We copied our Dev DB to our local machines onto the (localdb)\v11.0 instance of SQL Server, but we're running into an issue on everyone's computers except mine.

Here's the error we're getting:

The application could not connect to the database, please check the connection string in the web.config file and SQL server availability.

Original error:

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. The specified LocalDB instance does not exist. )

I've tried a ton of suggestions from other SO answers and other websites to figure out why we're getting this error (and why it's not happening on my machine), but no luck. We can connect to (localdb)\v11.0 in SSMS but we cannot connect to it through VS (same error). Also, when we open Sql Server Config Manager, we're not seeing any listings for SQL Server Services. Any ideas?

like image 711
Jerreck Avatar asked Nov 05 '14 23:11

Jerreck


1 Answers

  1. Make sure you have .NET Framework 4.0.2+ installed
  2. Set up your AppPool to run under the NetworkService account.
  3. Create a login for that account in your db.

    USE [master]; CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS; EXEC sp_addsrvrolemember N'NT AUTHORITY\NETWORK SERVICE', SYSADMIN;

  4. Share your instance with all users by running SqlLocalDB share Kentico KenticoShared

  5. Use connection string in the following format:

<add name="CMSConnectionString" connectionString="Data Source=(localdb)\.\KenticoShared;Initial Catalog=KenticoDB;Integrated Security=True;Connect Timeout=60" />

  1. If it doesn't help use a named pipe:

<add key="CMSConnectionString" value="Persist Security Info=False;Integrated Security=SSPI;database=KenticoDB;server=np:\\.\pipe\LOCALDB#D2BA6590\tsql\query;Current Language=English;Connection Timeout=120;" />

Notes:

  1. the exact name of the NetworkService account on your machine can be determined by running following C#

var ns = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).ToString()

  1. named pipe can be determined by running this in CMD: SqlLocalDB info KenticoShared
  2. don't forget to run your instance SqlLocalDB start KenticoShared
like image 128
rocky Avatar answered Sep 23 '22 01:09

rocky