I started to work with the Visual Studio 2012 and I created a new database project.
It seems very useful, but I cannot find any option to see my tables in a diagram view.
Where I can see all tables and the relationships belong them.
There is no such feature in Visual Studio Database Projects, and there never has been.
In the Data Sources pane, if you click on the icon called "Edit DataSet with Designer" You can create a diagram. That may be as close as you can get.
Related
Similar to this question, is there a way to visually display a database view in a database diagram?
Yes, though not using SSMS's Database Diagrams.
My solution for this is Microsoft BI's Data Source View (DSV). This requires that you have Microsoft's BIDS (Business Intelligence Development Studio), a component of SQL Server Standard (or higher) installed.
BIDS 2005 through 2016 should all work and provide the same basic functionality.
Alternatively, if you want access to a free version of the toolset, you can download and install SQL Server Express with Advanced Services ( basically SQL Express with Reporting Services added), though I have not worked with this version to verify.
With BIDS installed, launch it (or Visual Studio, if you have a more full version installed)
Go to File > New Project
In the New Project dialog, under Templates, expand Business Intelligence and choose a project. (I believe any BI project type will do. If you don't see any BI Projects, then you most likely do not have BIDS installed or at least installed with that version of Visual Studio).
Provide a location for this project to live on your machine.
Click OK to create the Visual Studio and BI Project.
In the Project Explorer pane, right-click the Data Sources folder and select New Data Source. Follow the Data Source "wizard" to create a connection to your desired data source. In the 2014 (and other?) version of BIDS, there is a question about the security credentials you'd like Analysis Services to use to connect to the data source. If you are just wanting to create a DSV for diagramming only, it doesn't matter what you select here.
Right-click the Data Source Views folder and choose New Data Source View. A Data Source View wizard launches.
Using the wizard, add the tables and views you would like to see in your data source view to the Included Objects pane using the left and right arrows.
Click Next to complete the table/view import and to give your DSV a name.
Click Finish to launch the import and see your initial diagram.
You now have a database diagram that includes both tables and views.
Here's a DSV of Microsoft's AdventureWorks2008 OLTP database. This image shows an example of what one can do with SQL views in DSVs. In it, I replaced the Employee table with the vEmployee View (gave it a friendly name of 'Employee') that exists in the database, and added logical primary key and foreign key relationships that mirror the PK/FKs of the underlying physical table.
Note that all changes made in a DSV are logical and therefore isolated to the DSV file itself and do not impact the database directly.
I want to generate an ER diagram of an SQL database using Microsoft SQL Server Management Studio (SMSS). However, I don’t know how to.
I found this technique online: Making ER Diagram from SQL Server 2008 Database
However, I am not able to see "Database Node" or "Database Diagrams" nodes as mentioned in the first and second steps.
Hence, how can I generate an ER diagram from an existing database?
From the comments, I realize that I was right in my understanding that Database node means the node with my database name. But then my problem is I am not able to find the "Database Diagrams" node under my Database name. What should I do so that I can see it?
PS: It’s not a local database.
Go to SQL Server Management Studio →
Object Explorer →
Databases →
Choose and expand your database.
Under your database, right click on "Database Diagrams" and select "New Database Diagram".
It will a open a new window. Choose tables to include in the ER diagram (to select multiple tables, press Ctrl or Shift key and select tables).
Click Add.
Wait for it to complete. Done!
You can save the generated diagram for future use.
Diagrams are back as of the 2019-06-11 release
Download the latest
As stated:
Yes, we’ve heard the feedback; Database Diagrams is back.
SQL Server Management Studio (SSMS) 18.1 is now generally available
Note: The latest version does not include it
Sadly, the last version of SSMS to have database diagrams as a feature was version v17.9.
Since that version, the newer preview versions starting at v18.* have, in their words "...feature has been deprecated".
Hope is not lost though, for one can still download and use v17.9 to use database diagrams which, as an aside for this question, is technically not an ER diagramming tool.
As of this writing it is unclear if the release version of 18 will have the feature. I hope so because it is a feature I use extensively.
From Object Explorer in SQL Server Management Studio, find your database and expand the node (click on the + sign beside your database). The first item from that expanded tree is Database Diagrams. Right-click on that and you'll see various tasks including creating a new database diagram. If you've never created one before, it'll ask if you want to install the components for creating diagrams. Click yes then proceed.
As of 2019-10, for SQL Server Management Studio, they did not upgrade it to add the create ER Diagram feature.
I would suggest try using DBeaver:
I am using both Mac and Windows and I was able to download the community edition. I logged into my SQL server database and was able to create the ER diagram using the DBeaver.
In order to create an ERD diagram for new projects I have been using Visual Studio's entity framework designer. Essentially I'm creating a "dummy project", adding entity framework via Nuget and diagramming away (I don't use Microsoft's Entity Framework thus the dummy project).
Is there another way to create such diagrams natively within Visual Studio 2010 Ultimate?
Assuming you already have a database, you can easily generate an ERD following the steps below.
Ensure you installed either Microsoft SQL Server Data Tools or Microsoft Web Developer Tools in order to get the Entity Data Model Designer.
These are the steps to generate an entity relationship diagram. It was tested in VS2012
Open Visual Studio
Create a project or open an existing project
(must be Visual Basic, Visual C# project, or Console Application)
Right-click the project and choose Add -> New Item…
Under Visual C# Items select “Data”
Select the template “ADO.NET Entity Data Model”
Give it a name and click “Add”
Select “Generate from database” or “Empty model”
If “Generate from database” selected enter connection
info, choose the database objects and done!
The model is stored as a “.edmx” file.
I use LINQ to SQL in a WPF project. I have made small changes in the database (changed datatype of the fields, which contain no data).
Now I want to regenerate (refresh) the LINQ to SQL DataContext of this project (I use VS 2008). I try to right-click on .dbml item in my Solution Explorer and choose "Refresh", but nothing happens.
How could I update the DataContext in a Visual Studio 2008 WPF project?
Without resorting to some 3rd party tools, the easiest way is just to delete the modified tables from the designer and drag them back in from Server Explorer.
Unfortunately, if you've made any manual modifications in the L2S designer they wont be preserved and you'll have to manually make the changes again.
huagati has a tool that claims to be able to refresh changes but I haven't tried it myself.
As other answers have stated it can only be done by deleting and re-adding the table. If you later move to Entity Framework however there is the ability to do exactly what you are looking for (there will be an "Update Model from Database" option in the context [right click] menu).
There is the command line tool sqlmetal.exe that autogenerates the .dbml file.
SQLMetalplus is a project that adds an extension to Visual Studio so that there is an Create/Refresh
https://github.com/thedemz/dotnet-sqlmetal-plus
Delete the Designer class file
Redrag the tables from Server Explorer to the designer.
I have this huge legacy database that I'm trying to get under source control. I looked around here on stackoverflow and decided to use the Visual Studio 2008 database project, then committing stuff on svn. I successfully imported the schema into the project, but I can't find any way to use the user-friendly table designers with this kind of project. Whenever I open a table, it opens the DDL definition. I need the designers, otherwise I won't get buy-in from the team. Any suggestions/workarounds?
I'd use Microsoft® Visual Studio Team System 2008 Database Edition GDR. Which scripts every object in it's own file so makes it easy to track in version control.
For developers that don't want to use the tool let them develop in Management Studio and then use the Schema Compare tool in Database Edition to automatically extract out the changes from their development database into the project files when they are ready to check-in.
You may be able to write some (cunning) Visual Studio macros to do the Schema Compare automatically with the minimum of clicking for developers.
I found sql server management studio (express free or the full product) easier to use than visual studio database projects. The one good thing i liked about vs was that you could select multiple objects (e.g. all tables) in the server explorer and generate a single script for them. These are not easy to maintain but are good for a quick back up of all objects.
Management studio has the table and query designers and also allows execution plans and client statistic to be displayed so you can optimize queries/sps if required.
I have only used it with visual source safe for source control which works fine from Management Studio point of view, but vss is not great! (buggy, crashes, corrupts etc.)
Try opening the Server Explorer (View > Server Explorer). You may need to add a connection and then you can to the database tables, right click them and choose "Show table data".
0nce you're there you get the Query Designer toolbar and you're able to use the table designers.