73

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?
4

1 回答 1

109
  1. LocalDB 是在 SQL Server 2012 CTP3 中引入的。它基本上是 SQL Express 的新版本,具有相同的功能,专用于开发人员。所以你不需要安装任何 SQL 服务器。如果您已安装 SQL 2012 或 Visual Studio 11,那么您已经拥有它,并且它在 .Net 4 或更高版本上运行。如果您使用的是 Visual Studio 11 并且一直在使用新的 EntityFramework 和 MVC,则可以在默认连接字符串上看到它。

  2. MDF 是 SQL Server 数据库文件的默认扩展名。(日志文件是 LDF)另见这个问题

  3. RESTORE DATABASE WITH MOVE您可以使用MSDN here上的文档恢复到特定文件夹。

  4. LocalDB 适用于开发人员,请参见第 1 点。

  5. SQL Server Express 博客在此处有一篇关于 LocalDB 的信息性文章。

于 2013-09-13T07:57:54.667 回答