简体   繁体   English

在Visual Studio中添加连接时看不到我的Northwind数据库

[英]Can't see my Northwind DB when adding connection in Visual Studio

As a beginner in C#/VS I want to practice making basic LINQ queries on simple DB's. 作为C#/ VS的初学者,我想练习在简单DB上进行基本的LINQ查询。 I downloaded the "famous" Northwind and Pubs databases on the official Microsoft websites ( https://www.microsoft.com/en-us/download/details.aspx?id=23654 ). 我在Microsoft官方网站( https://www.microsoft.com/zh-cn/download/details.aspx?id=23654 )上下载了“著名的” Northwind和Pubs数据库。 It gave me a .msi files that installed 6 files on my c: instnwnd.sql, instpubs.sql, NORTHWND.LDF, NORTHWND.MDF, PUBS.MDF, PUBS_LOG.LDF. 它给了我一个.msi文件,该文件在我的c上安装了6个文件:instnwnd.sql,instpubs.sql,NORTHWND.LDF,NORTHWND.MDF,PUBS.MDF,PUBS_LOG.LDF。

When I launch Visual Community 2015 and simply make an "Open => File..." and open the "instnwnd.sql", it opens the .sql file without problem. 当我启动Visual Community 2015并简单地创建一个“打开=>文件...”并打开“ instnwnd.sql”时,它将毫无问题地打开.sql文件。 The problem is when I'm trying to make a connection to the database, being either through the Solution Explorer (Data Connections => Add Connection) or while I'm trying to create an EDM (Database first), which is what I want to do eventually. 问题是当我试图通过解决方案资源管理器(Data Connections => Add Connection)与数据库建立连接时,或者当我试图创建EDM(首先是数据库)时,这就是我想要的最终要做。

The exact problem is that one : the Northwind and Pubs databases doesn't show up in the database list when i'm trying to add a connection, I only get the system databases. 确切的问题是:当我尝试添加连接时,Northwind和Pubs数据库未显示在数据库列表中,而我仅获得系统数据库。 Here is what I get : 这是我得到的:

http://img15.hostingpics.net/pics/128870screenshot1.jpg http://img15.hostingpics.net/pics/128870screenshot1.jpg

I read many MSDN documentation pages and several StackOverFlow topic about the matter (the closest of solving my issue was that one, but didn't work : How to connect to LocalDB in Visual Studio Server Explorer? ). 我阅读了许多MSDN文档页面和有关此问题的几个StackOverFlow主题(解决我的问题的最接近的方法是那个,但是没有用: 如何在Visual Studio Server Explorer中连接到LocalDB? )。 I have SQL Server Express 2014 with tools, started SQL services in my Windows Services etc. 我拥有带工具的SQL Server Express 2014,并在Windows服务中启动了SQL服务等。

What should I do in order to have those databases available so I can generate code and starting making my LINQ exercices ? 为了使这些数据库可用,我应该怎么做才能生成代码并开始制作LINQ练习?

Thanks in advance ! 提前致谢 !

You need to attach the databases before you can see them**. 您需要先附加数据库,然后才能看到它们**。 You're having a problem attaching the databases due to versioning (which is odd), but your sample db's are very old. 由于版本控制(这很奇怪),在附加数据库时遇到了问题,但是示例数据库的版本很旧。 Perhaps try newer ones from here https://northwinddatabase.codeplex.com/ and make sure you attach them before expecting them to show up in the tools. 也许从这里https://northwinddatabase.codeplex.com/尝试较新的版本,并确保在希望它们出现在工具中之前附加它们。

** Technically this is not true. **从技术上讲,这是不正确的。 I believe there is a way of connecting to sql server and passing a file path in the connection string, however this will likely still fail for your due to the error you get trying to attach the dbs you have. 我相信有一种连接到sql server并在连接字符串中传递文件路径的方法,但是由于您尝试附加数据库时出错,这可能仍然会失败。 Additionally, it requires a specially crafted connection string which may or may not be usable with the gui tools you're trying to use. 另外,它需要一个特制的连接字符串,该字符串可能与您尝试使用的gui工具一起使用,也可能无法使用。 It is also, in my opinion, a less common way of accessing sql server databases, so I would stick with attaching them first. 在我看来,这也是访问sql服务器数据库的一种不太常见的方式,因此我会坚持首先附加它们。 If you want to find out more about this, I believe the feature you need to research is called 'sql server user instances'. 如果您想了解更多信息,我相信您需要研究的功能称为“ sql服务器用户实例”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM