sql-serverssmslocaldb

SQL Server (localdb)\v11.0 explained


I'm following Code First to an Existing Database tutorial and noticed that it suggested to connect to (localdb)\v11.0 in learning purposes. I've tried to connect to it using my SQL Management Studio and it worked. But when I've restored a DB backup it created an [DatabaseName].mdf file in my user's directory.

I'm quite surprised and have following questions:

  1. What is a (localdb)\v11.0? Does it uses my SQL Express or SQL Compact?
  2. Does it support only databases stored in .mdf files?
  3. How can I specify path for my restore other than my user's folder?
  4. What general purposes does it serve (is it for learning purposes only)?
  5. Where can I find more info about this kind of database?

Solution

    1. LocalDB was introduced in SQL Server 2012 CTP3. It’s basically a new version of SQL Express, with same functionality, dedicated to developers. So you don’t need to install any SQL server. If you have installed SQL 2012 or Visual Studio 11 then you already have it, and it runs over .Net 4 or higher. If you are using Visual Studio 11 and have been playing with the new EntityFramework and MVC, you can see it on the default connection string.

    2. MDF is the default extension for SQL Server database files. (Log files are LDF) Also see this question.

    3. You can restore to a specific folder by using RESTORE DATABASE WITH MOVE as documented on MSDN here.

    4. LocalDB is intended for developers, see point 1.

    5. The SQL Server Express blog has an informative post about LocalDB.