Home > Enterprise >  How to create relationship diagram from .cs files in Models directory
How to create relationship diagram from .cs files in Models directory

Time:12-04

I have just used the Scaffold-DbContext command to generate a set of .cs files from an SQL Server database using EntityFrameworkCore and put them into a directory called Models.

Is there any way I can create an entity relationship diagram from the .cs files in the Models directory?

I recall I could do that in EntityFamework by selecting from the right click menu on Models but those features don't seem to be there for EntityFrameworkCore.

Can anyone help?

First I need to thank M. Mohabbati and Gert Arnold for their responses.

I need to add that I can see the Class Diagram for WPF and Console Apps but not for a Blazor app - see below .... enter image description here

Following the link provided by Gert Arnold I get to this link provided by yogibear that allows me to at least drag classes into the .cd file.

But boy, what a crock.

Can anyon tell me why I can't see and add the Class Diagram my Blazor App and why I have to follow Franco Morales amazing and torurous route to get anywhere?

Congratulations on discovering the method Franco, but why did you have to?

CodePudding user response:

Install Class Designer from Visual Studio Installer. Modify Visual Studio then go to Individual Components and find Class Designer.

Then add Class Diagram from Add --> New Item....

In the designer, you can add all classes you need. By default, there is no arrow to show the relations for example Inheritance or Composition association relationships.

By right-clicking on a class, you can show Base or Derived classes. And by right-clicking on a property you can show as Association.

NOTE: Class Designer is not available in .NET Core projects. Use Class Library project instead: Design and view classes and types with Class Designer

How to: Add class diagrams to projects

  • Related