Splitting big Entity model. (EF 5 onwards)

EF5 Onwards Only – The features, APIs, etc. discussed in this page were introduced in Entity Framework 5. Ref: Multiple Diagrams per Model (EF5 onwards)

In this demo I will show you how to split an entity model into multiple diagrams using the new enhanced EF designer.

Sometimes our model can become too large to edit or view.In earlier versions we could only have one diagram per EDMX file.In EF 5.0 we can split the model into more diagrams.

1) Launch VS 2012.

2) Create a New Project. From the available templates choose a Web Forms application

3) Add a new item in your project, an ADO.Net Entity Data Model. I have named it AdventureWorksLT.edmx.Then we will create the model from the database and click Next.Create a new connection by specifying the SQL Server instance and the database name and clickOK.Then click Next in the wizard.In the next screen of the wizard select all the tables from the database and hit Finish.

4) It will take a while for our .edmx diagram to be created. When I select an Entity (e.g Customer) from my diagram and right click on it,a new option appears “Move to new Diagram”.Make sure you have the Model Browser window open. Have a look at the picture below

5) When we do that a new diagram is created and our new Entity is moved there.

Have a look at the picture below

6) We can also right-click and include the related entities. Have a look at the picture below.

7) When we do that the related entities are copied to the new diagram.

Have a look at the picture below

8) Now we can cut (CTRL+X) the entities from Diagram2 and paste them back to Diagram1.

9) Finally another great enhancement of the EF 5.0 designer is that you can change colors in the various entities that make up the model.

Select the entities you want to change color, then in the Propertieswindow choose the color of your choice. Have a look at the picture below.

To recap we have demonstrated how to split your entity model in multiple diagrams which comes handy in EF models that have a large number of entities in them

Hope it helps!!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s