如何在 Visual Studio Server Explorer 中连接到 LocalDB? [英] How to connect to LocalDB in Visual Studio Server Explorer?

查看:32
本文介绍了如何在 Visual Studio Server Explorer 中连接到 LocalDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不敢相信经过一个小时的搜索,我找不到一个可行的解决方案.我正在关注关于 Entity Framework 6.0 的这篇文章,该文章对 Code First 进行了简单的演练.我创建了项目并安装了最新的 EF Nuget 包 以供项目编译.我还确认我安装了 Visual Studio 2013 附带的 Microsoft SQL Server 2012 Express LocalDB.我的本地计算机上没有安装任何其他 SQL 实例.程序运行并将条目添加到数据库中并在控制台中输出.但是当文章说检查您的本地数据库"时,它没有说明如何!我没有看到在项目文件夹下创建了任何.mdf"或.ldf"文件.我尝试了各种方法将 Visual Studio 的服务器资源管理器连接到 LocalDB.向导找不到 (localdb) 或在服务器资源管理器中找不到任何提供程序来接受连接字符串,如 (localdb)v11.0;Integrated Security=true; 我已经看到这在 StackOverflow 中询问了几个地方,但没有答案有效或标记为答案.请帮忙,这不必如此令人沮丧!

I can't believe I couldn't find a working solution to this after an hour of searching. I'm following this article on Entity Framework 6.0 which gives a simple walk-through on Code First. I created the project and installed the latest EF Nuget package for the project to compile. I also verified that I have Microsoft SQL Server 2012 Express LocalDB installed which came with Visual Studio 2013. I don't have any other instances of SQL installed on my local computer. The program runs and entries are added to the database and outputted in the console. But when the article says "check your localdb" it doesn't say how! I don't see any '.mdf' or '.ldf' files created under the project folder. I tried every way to connect Visual Studio's Server Explorer to LocalDB. The wizard cannot locate (localdb) or cannot find any provider in Server Explorer to accept connection string like (localdb)v11.0;Integrated Security=true; I've seen this asked several places in StackOverflow but no answer works or marked as answer. Please help, this doesn't have to be this frustrating!

将 Visual Studio Server Explorer 连接到 LocalDB 的步骤是什么?

What are the steps to connect Visual Studio Server Explorer to LocalDB?

推荐答案

好的,回答我自己的问题.

OK, answering to my own question.

将 LocalDB 连接到 Visual Studio Server Explorer 的步骤

Steps to connect LocalDB to Visual Studio Server Explorer

  1. 打开命令提示符
  2. 运行SqlLocalDB.exe start v11.0
  3. 运行SqlLocalDB.exe info v11.0
  4. 复制以 np:... 开头的实例管道名称
  5. 在 Visual Studio 中选择 TOOLS > Connect to Database...
  6. 对于服务器名称,输入 (localdb)v11.0.如果它不起作用,请使用您之前复制的实例管道名称.您还可以使用它来连接 SQL Management Studio.
  7. 在下一个下拉列表中选择数据库
  8. 点击确定
  1. Open command prompt
  2. Run SqlLocalDB.exe start v11.0
  3. Run SqlLocalDB.exe info v11.0
  4. Copy the Instance pipe name that starts with np:...
  5. In Visual Studio select TOOLS > Connect to Database...
  6. For Server Name enter (localdb)v11.0. If it didn't work, use the Instance pipe name that you copied earlier. You can also use this to connect with SQL Management Studio.
  7. Select the database on next dropdown list
  8. Click OK

这篇关于如何在 Visual Studio Server Explorer 中连接到 LocalDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆