How to Create an ORM Diagram Visually
An Object-Relational Mapping (ORM) diagram is more than just a tool; it is the blueprint for how your .NET application communicates with its database. ORM diagrams provide a clear, visual representation of your data model structure, showing entities (like classes), their properties (fields), and the relationships between them (such as one-to-many or many-to-many).
In the world of .NET development, especially when working with Entity Framework Core (EF Core), ORM diagrams play a crucial role. Creating these diagrams visually transforms a complex task into an engaging, almost drag-and-drop experience. It speeds up development, reduces errors, and bridges the gap between technical and non-technical stakeholders.
This tutorial provides a step-by-step explanation of everything you need to create an ORM diagram visually. It uses the Model-First ORM design approach that lets you design your data model first and then generate the EF Core code and the database schema from it.
Also, in this tutorial, we'll use Entity Framework Core (EF Core) as the ORM technology and Devart's Entity Developer as the visual design tool. Entity Developer is a powerful visual modeling tool that lets you design your EF Core models visually, configure entity mappings, and generate high-quality code automatically.
New to ORM? Check out this article to learn more about it: What is ORM?
Create classes
In Entity Developer, a class represents a real-world concept in your application, such as Customer, Order, or Product. The ORM diagram directly maps entity classes to corresponding database tables, each performing a single responsibility. For instance, Customer is a class with the responsibility of someone buying a product, and Product is a class representing something you sell.
To create a class, follow the steps below:
- Set up the Entity Developer:
- Download and install Entity Developer.
- After installation, launch the application.
- You will be prompted to choose your ORM; select EF Core.
- Select Model-First approach as your Model type.
- Add a new class:
- In the ORM diagram space, right-click or use the toolbar.
- Click Add > New Class.
- Name your class and click OK.
To create all the classes you have in your database, repeat the actions listed in Step 2. Also, when naming your classes and other elements, follow the PascalCase naming convention. For more details, see the table below.
| Element | Convention | Example |
|---|---|---|
| Class names | PascalCase, singular | Customer, OrderDetail |
| Property names | PascalCase, descriptive | FirstName, OrderDate |
| Primary key | Id or EntityNameId | Id, CustomerId |
| Navigation property | Plural for collections, singular for single | Orders, Customer |
Create properties
After you have created your classes, the next step is to create the properties of each class. In Entity Developer, properties mean the data contained in each class you have created. It represents the columns in your database and the fields in your EF Core model.
When creating your property, make sure to give it a name that clearly describes the data it contains. For instance, OrderDate, CustomerId, and FirstName.
To create properties, follow the steps below:
- Add a property to each class you have created:
- In your ORM diagram, select the entity class you want to add a property to.
- Click Add > New Property.
- Enter the property name.
- Set the data type:
After you have entered the name of your property, click the Type checkbox and select a .NET data type from the dropdown. For example:
- string - for text (nvarchar)
- int - for integers (int)
- decimal - for prices (decimal(18,2))
- DateTime - for dates
- Boolean - for yes/no values
This will automatically map .NET types to the corresponding SQL types.
- Select the Primary Key checkbox and click OK.
- Add constraints.
A constraint is used to define the mandatory fields, the maximum length of strings, or default values for properties. To set constraints, follow the steps below:
- Once you have set the Primary Key, the Column Editor page pops up for you to set your desired constraints.
- Select the necessary checkbox and enter your desired Length, Precision, or Scale.
- Click OK to set the constraints you have entered.
Create associations
In real-world applications, data objects aren't isolated - they are connected. A Customer places Orders. A Product belongs to multiple Categories. In ORM, these connections are referred to as associations.
Associations represent how two classes (or database tables) are related. In EF Core, these are called navigation properties and usually correspond to foreign keys in the database.
There are three major types of associations in Entity Developer:
- One-to-one relationship: In this kind of relationship, each record in one table corresponds to exactly one record in another table. One-to-one relationship is commonly
used for splitting data into separate tables for modularity, security, or performance reasons.
For example: Customer ↔ ShippingDetail
- One-to-many relationship: This kind of relationship means that one record in Class A can be associated with many records in Class B.
For example: Customer → Order
- A single Customer can have many Orders.
- Each Order belongs to one Customer.
- Many-to-many relationship: Many records in Class A can be associated with many records in Class B.
For example: Product ↔ Category
- A Product can belong to many Categories.
- A Category can include many Products.
In this tutorial, you will create one-to-many and many-to-many associations. Follow the steps below to create each of these.
- Creating a one-to-many relationship:
- Select the classes you want to use in creating a one-to-many relationship. For example, Customer → Orders.
- Click Customer, then click Orders.
- Click Add > New Association.
- Choose the Cardinality, or type of association you want to create.
- Fill out the necessary details.
- Select the Generate related property checkbox.
- Click OK.
- Check the toolbar on the left-hand side to see the result under Associations.
-
Creating many-to-many relationships:
- Select the classes you want to use in creating many-to-many relationships.
For example, Product ↔ Category.
- Create a junction table:
- Add a new entity, for example, ProductCategory.
- Add foreign keys:
- ProductId: Link to the Product
- CategoryId: Link to the Category
These should both be primary keys (composite key).
- Choose the Cardinality, or type of association you want to create.
- Complete the Relation Class, Modifier, and Name on End 1 and End 2.
- Complete the ProductCategory Properties on End 1 and End 2.
- Click OK.
- Select the classes you want to use in creating many-to-many relationships.
- Check the toolbar on the left-hand side to see the result under Associations.
Create inheritances
In database applications, most entities are just specialized versions of a broader concept. For instance, a User in an application might also be an Admin, a Customer, or a Vendor.
Inheritance in ORM lets you define the common properties of these entities in a base class and then create specialized derived classes that inherit from the base and add unique fields. After you have created the inheritance between entities in the ORM diagram, you can visualize this as a tree structure, where derived entities extend a base entity.
To create an inheritance, follow the steps below:
- Add the Base and Derived Entities. For example: Customer (base), Order, Admin (derived).
- Right-click and choose Add > New Inheritance.
- Click the base entity (for example, Customer), then the derived entity (for example, Orders).
- A line with a triangle should appear from the derived class pointing to the base.
- In the Inheritance Editor, fill out the necessary details for General, Discriminator Value, and Discriminator.
- Click OK to complete the creation of the inheritance.
- Check the toolbar on the left-hand side for results.
DbContext and entities code generator
After you have created your visual ORM model following the four steps above, the next step is to let Entity Developer generate your actual EF Core code. This includes the DbContext class and all your entity classes. To generate your EF code, follow the steps below:
- Open the ORM model you have created.
- In the title bar, click Model > Generate Code or press F7.
-
Under Code Generation, choose:
- Language: C#
- EF Core version
-
Generation Template: Choose between:
- Fluent Mapping
- Data Annotations
- Mixed (if supported)
- Select the folder you want to save the generated code in.
- Generate your code.
What is generated?
DbContext Class
This class represents your session with the database and manages the following:- Entity tracking
- Queries
- Migrations and schema syncing
Example:
public class MyAppContext : DbContext
{
public DbSet Customers { get; set; }
public DbSet Orders { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Fluent API config goes here (if chosen)
}
}
Entity classes
Each visual entity becomes a C# class with all its properties and relationships.
Using Data Annotations:
public class Customer
{
[Key]
public int Id { get; set; }
[Required, MaxLength(100)]
public string Name { get; set; }
public ICollection < Order > Orders { get; set; }
}
Using Fluent API:
The entity class is cleaner and the configuration goes into OnModelCreating() in DbContext.
// In Customer.cs
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection Orders { get; set; }
}
// In OnModelCreating():
modelBuilder.Entity()
.HasKey(c => c.Id);
modelBuilder.Entity()
.Property(c => c.Name)
.IsRequired()
.HasMaxLength(100);
ORM diagram examples
Example 1: eCommerce
Use case: An online store where customers can browse products, place orders, and track shipping.
Visual features of the eCommerce ORM diagram
| Class | Properties | Navigation Properties | Constraints |
|---|---|---|---|
| Customer |
|
|
|
| Order |
|
|
|
| ShippingDetail |
|
|
|
| Product |
|
|
|
| Category |
|
|
|
| OrderItem |
|
|
|
| ProductCategory |
|
|
|
Example 2: Blog platform
Use case: A blog system where users can write posts, add tags, and leave comments.
Visual features of the blog ORM diagram
| Class | Properties | Navigation Properties | Constraints |
|---|---|---|---|
| User |
|
|
|
| Post |
|
|
|
| Comment |
|
|
|
| Tag |
|
|
|
| PostTag (junction table for many-to-many) |
|
|
|
Example 3: Quiz system
Use case: A quiz platform where users can take quizzes that contain multiple questions. Each question has multiple answers, but only one is correct. User results are stored for reporting.
Visual features of the quiz system ORM diagram
| Class | Properties | Navigation Properties | Constraints |
|---|---|---|---|
| User |
|
|
|
| Quiz |
|
|
|
| Question |
|
|
|
| Answer |
|
|
|
| Result |
|
|
|
Other advantages of Entity Developer
Entity Developer goes beyond basic modeling; it's a comprehensive tool tailored for real-world development needs. Here are other reasons why it stands out:
- Multi-ORM support: Whether you're working with Entity Framework Core, NHibernate, LINQ to SQL, or even EF Classic, Entity Developer has you covered. You can switch between frameworks without switching tools.
- IDE integration: Seamlessly integrates into Visual Studio, so you can model, generate code, and manage your database schema without leaving your primary development environment.
- Custom code generation templates: Entity Developer offers T4-based templates that you can tweak or extend. Want to follow a specific project architecture or naming convention? You can automate it with custom templates.
- Built-in validation rules: Entity Developer provides immediate feedback when your model violates relational or ORM-specific rules, helping you catch and fix issues before they cause runtime errors.
Conclusion
Designing an ORM diagram visually, especially with a Model-First approach, enables you to understand relationships, spot issues early, and build clean, maintainable systems.
Entity Developer shines in this space. It simplifies complex database models, supports multiple ORMs, and generates high-quality code that fits right into your .NET stack. Whether you're building a blog, an eCommerce platform, a quiz system, or any other application, Entity Developer lets you start with clarity and confidence.
If you're looking to streamline your EF Core workflow, reduce human error, and bring your data models to life, visual ORM design with Entity Developer is the way forward.