Why the instance name of SQL Server Express is changing?
Question
I’m working on a web app which is using
SQL Server Express (Microsoft SQL Server 2016 (SP1) (KB3182545) –
13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 6.3
(Build 18362: )).
The web app is using connection string to connect to DB. After searching for a few days for a proper connection string format I managed to find the format, using method described by Nik in this blog post and it is:
Everything was working fine yesterday, but today it stopped. I discovered that the service name has changed to:
After replacing the instance name with the new service name in the connection string the web app works well, but it’s not an acceptable solution.
Can you tell me why the instance name is changing, is it any Express version limitation? How can configure the name to be permanent?
asked 2020-05-21 by maniacz
Answer
This app isn’t using the regular SQL Server Express Edition. Express Edition runs as a service such that you’d see it in the Services control panel (on Windows), and there would be a stable instance name, as you’re expecting.
This service you’re connecting to uses the (confusingly named) SQL Server Express LocalDB. This is often referred to as just “LocalDB” to reduce the confusion of the name overlap. LocalDB runs in process–that is, it isn’t a service, but is started up by the app that uses is.
LocalDB supports a number of configurations, depending on how the application is intended to be accessed. Check out the section in the docs titled “Automatic and Named Instances” as well as the section titled “Shared Instances of LocalDB“.
answered 2020-05-21 by Andy Mallon