What Is LocalDB?
SQL Server Express LocalDB is a lightweight version of SQL Server designed for developers. It runs in user mode, requires minimal setup, and is ideal for local development scenarios.
LocalDB is a minimal, on-demand version of SQL Server Express. It is:
- Easy to install and use.
- Runs as a user process, not a service.
- Ideal for development and testing.
- Compatible with Entity Framework and other .NET data access technologies.
Managing LocalDB with SqlLocalDB.exe
The SqlLocalDB.exe utility is used to manage LocalDB instances from the command line.
Common Commands
-
List instances:
SqlLocalDB.exe info -
Create a new instance:
SqlLocalDB.exe create MyInstance -
Start an instance:
SqlLocalDB.exe start MyInstance -
Stop an instance:
SqlLocalDB.exe stop MyInstance -
Delete an instance:
SqlLocalDB.exe delete MyInstance -
Get instance info:
SqlLocalDB.exe info MyInstance
ref: SqlLocalDB Utility - SQL Server | Microsoft Learn
Connection Strings for LocalDB
LocalDB uses specific connection strings to connect to instances.
Basic Connection
Server=(localdb)\MSSQLLocalDB;Integrated Security=true
With Attached Database File
Data Source=(LocalDb)\\MSSQLLocalDB;
AttachDbFilename=|DataDirectory|\\Oqtane-202503231608.mdf;
Initial Catalog=Oqtane-202503231608;
Integrated Security=SSPI;
Encrypt=false;
Note
Integrated Security=SSPIsame asIntegrated Security=trueexcept that the later throws an error when used with an Oledb provider.
ref: Connection String Syntax - ADO.NET | Microsoft Learn
Location of Database Files
LocalDB stores database files in user-specific directories.
System Instances
%userprofile%\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB%userprofile%\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\LocalDBApp1
User-Created Databases
%userprofile%\Documents\
ref: SQL Server Express LocalDB - SQL Server | Microsoft Learn