Install SQL Server 2012 Express LocalDB


First let us know: If you have installed Visual Studio 2012 or 2013, normally you do NOT have to install SQL Server Express LocalDB separately because "In Visual Studio 2013 (and in 2012), LocalDB is installed by default with Visual Studio." (from here)

What is SQL Server Express LocalDB?

If you think SQL Server Express is a mini version of SQL Server, then we can call LocalDB is a mini version of SQL Server Express.

Microsoft SQL Server 2012 Express LocalDB is an execution mode of SQL Server Express targeted to program developers. LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. from here.

We should care about the instances generated ways: Automatic and Named instances: Automatic instances of LocalDB are public. They are created and managed automatically for the user and can be used by any application; Named instances of LocalDB are private. They are owned by a single application that is responsible for creating and managing the instance.

LocalDB is not a replacement for SQL Server Express -- it is an addition to SQL Server Express lineup. (form here)

So since we have already had LocalDB with our Visual Studio, we just use it direcly.

How to use?

Let us try a simple command: SqlLocalDB versions


We can see we got a LocalDB version information, so that confirmed we really have a SQLLocalDB installed.

All commands listed here. Note: some commands might let us be confused, for example: "SQLLocalDB version | v " means we can use either "SQLLocalDB version" or "SQLLocalDB v " , not combined format "version | v " .

Walkthrough: Creating a Local Database File in Visual Studio.

Actually every time when you create a new web application in Visual Studio 2013 by default wizard steps, you have already got a default LocalDB connection string, check your web.config file:

 <add name="DefaultConnection" 
    connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebMVC4_5test-20140124062917.mdf;Initial Catalog=aspnet-WebMVC4_5test-20140124062917;Integrated Security=True" 
    providerName="System.Data.SqlClient" />

Then you can follow this post to continue what you want to do.

Manually installation ?

If you want to download and install SQL Server LocalDB, you can find information from here or here.