C# Visual Studio 2012 数据库图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14131304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:45:08  来源:igfitidea点击:

Visual Studio 2012 Database Diagram?

c#sqlvisual-studiovisual-studio-2012

提问by Flaxbeard

I have done very little in C# and am following the Head First C# book. There's a part in the book where it asks me to create a Database Diagram for my SQL database, but in the Database Explorer there is no Database Diagram node/folder.

我在 C# 方面做得很少,并且正在关注 Head First C# 一书。书中有一部分要求我为我的 SQL 数据库创建数据库图,但在数据库资源管理器中没有数据库图节点/文件夹。

I have heard that Microsoft dropped the Database Diagram feature, but is there another way to create a Database Diagram that would be easy enough for me to understand?

我听说 Microsoft 放弃了数据库图功能,但是有没有另一种方法可以创建一个让我很容易理解的数据库图?

采纳答案by jchapa

Give SQL Server Management Studio a try. It has a table diagram tool. Here's the express edition (SQL Server 2008 Express): http://www.microsoft.com/en-us/download/details.aspx?id=7593

试试 SQL Server Management Studio。它有一个表格图表工具。这是快速版(SQL Server 2008 Express):http: //www.microsoft.com/en-us/download/details.aspx?id=7593

You can find it for 2012 SP1 here, as well: http://microsoft.com/en-us/download/details.aspx?id=35579

您也可以在此处找到 2012 SP1:http: //microsoft.com/en-us/download/details.aspx?id=35579

回答by JBrooks

I like the way Entity Framework 5 will allow you to import database objects and then it will diagram the tables, indexes, relationships, etc. Or you can do it the other way, create the diagrams and then publish it to a database. This works so well I suspect it is why the Database Diagram was dropped in SQL Server. EF5 is probably in your Visual Studio environment right now.

我喜欢 Entity Framework 5 允许您导入数据库对象,然后它会绘制表格、索引、关系等的方式。或者您可以用另一种方式,创建图表,然后将其发布到数据库。这非常有效,我怀疑这就是数据库图表被删除到 SQL Server 中的原因。EF5 现在可能在您的 Visual Studio 环境中。

EF5

EF5

To create an EF5 diagram, right click a directory (usually the directory is named "Model"), and select "Add" / "New Item" and then select "ADO.NET Entity Data Model". Name it, and then select "Generate from database". The rest is selecting or generating a connection string and then selecting the database objects.

要创建EF5图表,请右键单击一个目录(通常该目录名为“Model”),然后选择“Add”/“New Item”,然后选择“ADO.NET Entity Data Model”。命名它,然后选择“从数据库生成”。剩下的就是选择或生成连接字符串,然后选择数据库对象。

Best part is that this is the start of what I would recommend when you get to the point in your learning where you need a data access layer, I can not recommend EF5 high enough.

最好的部分是,当您在学习中需要数据访问层时,这是我推荐的开始,我不能推荐足够高的 EF5。

回答by MikeH

I just solved a similar problem - my VS2012 server explorer was not showing Database diagrams

我刚刚解决了一个类似的问题 - 我的 VS2012 服务器资源管理器没有显示数据库图表

The problem was that the database I was using was the SQLEXPRESS installed by VS2012 (and was sql 2012 based)

问题是我使用的数据库是 VS2012 安装的 SQLEXPRESS(并且基于 sql 2012)

I am using SSMS 2008R

我正在使用 SSMS 2008R

When I moved the offending database to a SQL 2008R2 server - my database diagrams appeared

当我将有问题的数据库移动到 SQL 2008R2 服务器时 - 我的数据库图表出现了

This took many hours to resolve and I hope this note helps somebody else save this frustration

这花了好几个小时来解决,我希望这篇笔记可以帮助其他人避免这种挫败感