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
- I changed Server to Data Source
- Changed the name of my instance and host to the actual SQL instance name and computer respectively.
- 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
- Make sure you have .NET Framework 4.0.2+ installed
- Set up your AppPool to run under the NetworkService account.
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;Share your instance with all users by running
SqlLocalDB share Kentico KenticoShared
- Use connection string in the following format:
<add name="CMSConnectionString" connectionString="Data Source=(localdb)\.\KenticoShared;Initial Catalog=KenticoDB;Integrated Security=True;Connect Timeout=60" />
- 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:
- 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()
- named pipe can be determined by running this in CMD:
SqlLocalDB info KenticoShared
- don't forget to run your instance
SqlLocalDB start KenticoShared
Related Topics
Plain Old Clr Object VS Data Transfer Object
Get Public/External Ip Address
Why Does One Often See "Null != Variable" Instead of "Variable != Null" in C#
The Order of Elements in Dictionary
How to Have an Auto Incrementing Version Number (Visual Studio)
Get Output Parameter Value in Ado.Net
Use a Variable from Another Method in C#
Setting Wpf Image Source in Code
Linq to Entities Case Sensitive Comparison
Floating Point Comparison Functions For C#
Which Parsers Are Available For Parsing C# Code
Should I Avoid 'Async Void' Event Handlers
Display Lines Number in Stack Trace For .Net Assembly in Release Mode