Multiple Diagrams Per Model With Entity Framework and Visual Studio 2013


In the Model (or Database) First Approach, when we create a model using the Entity Data Model wizard of the Entity Framework designer. The EDMX file will be created and added to the solution. The Entity Framework designer contains the following components:

  1. Design surface for editing the model (we can add a new entity, update an existing one or delete the entity or any relation or association)
  2. Model Browser: This window provides the tree views of the model
  3. Mapping Details: This window is useful for viewing and updating mappings.

Mapping of Entity in Model Diagram


Problem Statement

By default, the Entity Framework designer creates one diagram for viewing entities in the conceptual model. If we are dealing with a large number of entities and associations, it is very difficult to see or determine an entity in the diagram. Can we split them up logically into a different diagram?


In Visual Studio 2012 onward, we can view our conceptual model in multiple diagrams. Visual Studio provides the facility to split the entity diagram into multiple diagrams at design time. It means we can have multiple diagrams for one Entity Data Model.


Suppose I have four entities called DepartmentMaster, EmployeeMaster, OrderMaster, and OrderDeail in one diagram.

Entity Model Diagram

Add New Diagram

We can add a new diagram by right-clicking on the diagram node in the model browser and selecting the "Add New Diagram" option. We can rename this diagram. In the preceding example, I have created a new diagram named "MyNewDiagram” and I want to move all Order related entities with it.

Adding New Diagram

We can drag and drop entities from the model browser to a new diagram.


View Entity Types


Move Entities from Existing Diagram to New Diagram

We can also move the entities from an existing diagram to a new diagram by just selecting the option called "Move to new diagram". For example, I want to move the orderMaster and OrderDetail entities to a new diagram then select both entities from the diagram and right-click on the entities, and select the option called "Move to new Diagram" from the context menu. It creates a new diagram and moves selected entities (OrderMaster and OrderDetail) into the new diagram.

Moving Entities to New Diagram

Include Related Entity

We can also include related entities of any specific entity. In the above example, an Employee is related to the order, we can in the Order diagram by right-clicking on an entity and select "Include Related". Now the Employee entity is available in both diagrams.


Include Related Entity

We can also remove the entity from the diagram by just right-clicking on the entity and selecting the "Remove from diagram" option from the context menu.


Removing Entity Diagram

This option removes an entity from the diagram, not from the entity model, whereas the "Delete from Model" option is used to delete the entity from the entity model.

Changing the Color of Entities

We can also change the color of our entities. To change the color of the entities, first select entities from the diagram (design surface), right-click, and select the "Properties" option from the context menu. In the properties window, select the Fill Color property. We can specify the color by either selecting a valid color name or a valid RGB value.


Changing Color of Entities

Change Properties Sequence

We can also change the sequence of the properties of any specific entity by right-clicking on a property and selecting the "Move Properties" option and selecting up, down, top, and so on.


Moving Properties of Entity



In this article, we learned how to split a model into multiple diagrams, how to specify a different color for an entity, and how to change the sequence of the property in a specific entity.