SQL Network Interfaces, Error: 50 - Local Database Runtime Error Occurred. Cannot Create an Automatic Instance

SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance

Breaking Changes to LocalDB: Applies to SQL 2014; take a look over this article and try to use (localdb)\mssqllocaldb as server name to connect to the LocalDB automatic instance, for example:

<connectionStrings>
<add name="ProductsContext" connectionString="Data Source=(localdb)\mssqllocaldb;
...

The article also mentions the use of 2012 SSMS to connect to the 2014 LocalDB. Which leads me to believe that you might have multiple versions of SQL installed - which leads me to point out this SO answer that suggests changing the default name of your LocalDB "instance" to avoid other version mismatch issues that might arise going forward; mentioned not as source of issue, but to raise awareness of potential clashes that multiple SQL version installed on a single dev machine might lead to ... and something to get in the habit of in order to avoid some.

Another thing worth mentioning - if you've gotten your instance in an unusable state due to tinkering with it to try and fix this problem, then it might be worth starting over - uninstall, reinstall - then try using the mssqllocaldb value instead of v12.0 and see if that corrects your issue.

SQL Network Interfaces Error 50 - Local Database Runtime error occurred. Cannot create an automatic instance

Found my error by chance!

  public PhotocopierDBContext()
: base("PhotocopierInformationManagementServicesEntities")
{
}

Got rid of this and everything works!

error: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid ON JETBRAIN RIDER

Modifying my connection string as squillman suggested and removing one backslash solved my problem. Here is how the connection string looks like:

@"Data Source=abdullahi\SQLEXPRESS;Database=Library;Trusted_Connection=True;MultipleActiveResultSets=True"

NOTE

  1. I changed Server to Data Source
  2. Changed the name of my instance and host to the actual SQL instance name and computer respectively.
  3. Removed the escape backslash character because the entire string is preceded by @

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


  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


Related Topics



Leave a reply



Submit