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服务器资源管理器到LocalDB的步骤是什么?


当前回答

Visual Studio 2015 RC,已经安装了LocalDb 12,类似于之前的说明,但仍然不应该被要求知道“魔术”,在使用之前,默认实例应该已经打开… 咆哮完毕,无解:

cmd> sqllocaldb start

会显示

LocalDB instance "MSSQLLocalDB" started.

您的实例名可能不同。无论哪种方式,弹出到VS,打开服务器资源管理器,右键单击数据连接,选择添加,选择SQL Server,在服务器名类型中:

(localdb)\MSSQLLocalDB

不输入数据库名称,单击“Test Connection”。

其他回答

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

连接LocalDB到Visual Studio Server Explorer的步骤

打开命令提示符 运行SqlLocalDB.exe start v11.0 执行SqlLocalDB.exe info v11.0命令 复制以np:\…开头的实例管道名 在Visual Studio中选择工具>连接到数据库… 对于服务器名输入(localdb)\v11.0。如果它不起作用,请使用前面复制的Instance管道名。您还可以使用它来连接SQL Management Studio。 在下一个下拉列表中选择数据库 单击OK

使用SQL Server 2017和Visual Studio 2015,我使用本地主机\SQLEXPRESS

修理不起作用。

与示例插图中一样,所有这些步骤都只提供对“系统”数据库的访问,而没有选择要访问的现有用户数据库的选项。

访问本地(非Express Edition) Microsoft SQL server实例的解决方案驻留在SQL server端:

打开运行对话框(WinKey + R) 类型:“services.msc” 选择SQL Server浏览器 单击“属性” 将“禁用”改为“手动”或“自动” 当“Start”服务按钮启用时,单击它。

完成了!现在,您可以从连接属性中的“服务器名称”列表中选择本地SQL Server。

以admin用户运行CMD。

from start menu 'cmd' - wait for it to find it. Right click on cmd, and select open as administrator type : cd C:\Program Files\Microsoft SQL Server\120\Tools\Binn type : SqlLocalDB start now type : SqlLocalDB info Shows the running sql instances available... choose what you want... to find more about the instance type : SqlLocalDB info instanceName now from VS you can setup your connection In VS, View/Server Explorer/(Right click) Data Connections/Add Connection Data Source: Microsoft SQL Server (SqlClient) Server name: (localdb)\MSSQLLocalDB Log on to the server: Use Windows Authentication Press "Test Connection", Then OK. job done

请使用SQL Server对象资源管理器(SSOX)

与其他答案不同,这种方法使用: —无特殊命令。 —无复杂配置。 只需使用SQL Server对象资源管理器

这很简单……

从“视图”菜单中,打开SQL Server对象资源管理器。

右击{YourTableName}表>视图设计器

完成了。