Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio start localdb and how can I stop that?

Tags:

I'm trying to optimize my Visual Studio experience and my machine in general. I noticed that I have two instances of SQL Server running, one of which is LocalDB. This gets started by Visual Studio.

I would rather it didnt start local db at all but I can imagine it uses it for a few things. Since I already have a full sql instance running it would be better if it used that.

Does anyone know if I can stop this from starting or at least not starting it until it really needs it?

like image 857
Jonesie Avatar asked Apr 07 '15 20:04

Jonesie


People also ask

How do I stop LocalDB?

Be aware that LocalDB has the same limitations as SQL Server Express. Finally, you can stop the instance through the stop command: C:\Program Files\Microsoft SQL Server\120\Tools\Binn>SqlLocalDB.exe stop tugberk LocalDB instance "tugberk" stopped.

What is LocalDB in Visual Studio?

Once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the local AppData path, which is normally hidden.


2 Answers

The following procedure worked for me.

(Caveat: I don't use LocalDB at all, so I don't care if this procedure disables it completely. You may feel differently.)

  1. Make sure Visual Studio is not running.
  2. Run Visual Studio and go to the SQL Server Object Explorer.
  3. Right-click each LocalDB instance and choose Delete, or if Delete is unavailable, choose Disconnect.
  4. Close Visual Studio.
  5. Kill all sqlservr.exe instances that were launched by Visual Studio.
  6. Go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\SSDT\SqlServerObjectExplorer and verify that it has no ServerInstance subkeys, for example ServerInstance1, ServerInstance2, etc.
  7. Rename HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Local DB so Visual Studio can't find it (for example, append .DISABLED to the key name).
  8. Run Visual Studio and enjoy your LocalDB-free experience.

Please note that you will need to repeat this procedure every time you install an update to SQL Server Data Tools (SSDT), since the installer re-adds the key you renamed.

like image 62
Rand Scullard Avatar answered Sep 22 '22 15:09

Rand Scullard


LocalDB does not run as a service like SQL Server Express. It will start and stop/automatically as needed.

LocalDB doesn't create any database services; LocalDB processes are started and stopped automatically when needed. The application is just connecting to "Data Source=(localdb)\v11.0" and LocalDB process is started as a child process of the application. A few minutes after the last connection to this process is closed the process shuts down.

Introducing LocalDB, an improved SQL Express - SQL Server Express Blog

like image 44
Cory Avatar answered Sep 18 '22 15:09

Cory