Generating ERD diagrams within Visual Studio - database

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.

Related

Cannot find ado.net entity data model in visual studio 2022

I want to start a new project in ASP.NET core MVC web application. In the past I'm used to starting with the code, I create the code and I create the dbContext and I make the migration of the data Add-Migration and Update_Migration and finally I can get my database. This time I want to start with the database first, I loaded SSMS(SQL server management studio) and created the database and after I want to generate the classes from the database but It didn't work, I cannot find the ado.net entity data model in visual studio 2022.
I tried to solve this problem by myself, I added these packages(in the picture below) but also it didn't work
Can you please suggest what I am doing wrong?

Is there a way to visually display a database view in a database diagram?

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.

How do I generate a dbml file?

How do I generate a dbml file?
In a Visual Studio file, A project contains a DBML file that, when opened, shows a very cool representation graphical of a database and all the interconnections between the tables.
I want that for another project for documentation purposes. The database already exists. So how do I get from the sql server database with all the key relationships and the proverbial whole nine yards to the cool graphic representation of ta DBML file as seen in visual studio.
I did some searching on the internet with several search engines and so far everything I see is working in the other direction such as "create database from DBML file? "
It seems to have something to do with LINQ but I have yet to find an explanation about this.
In Visual Studio, right click on your project in the Solution Explorer, on the folder where you want to add the DBML. Choose Add New Item, then under Data, choose Linq-To-SQL Classes. This will create an empty DBML file. You'll then need to create a server connection to a database and drag the tables you want into the DBML designer. Once you save, Visual Studio will regenerate the DBML with entities for your chosen tables.
Also there are various tools, such as Plinqo, which generate DBML files and offer robust templatimg solutions for more advanced code generation.

Visual Studio 2012 Database Project Diagram View

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.

Visual Studio database project designers

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.

Resources