Home > English > Working with large Entity Framework models in Visual Studio

Working with large Entity Framework models in Visual Studio

Entity Framework has come a long way. It has provided a lot of flexibility and now with Code First, it is getting closer and closer to the flexibility of NHibernate. It still lacks some features that will hopefully be in the next drop.

An issue that I have run into in dealing with very large models in my projects is the lack of good designer support. Take the following screen shot from the AdventureWorks database:

When the model is this small, Visual Studio give us the ability to navigate between entities using the Property dropdown selector as seen here:

However if you have a model that is considerably larger model like the following screen shot:

The dropdown will no longer work as seen here:

Luckily there is still a way to navigate your large model without needing to drop everything and recreate. Let me introduce you to the Model Browser. To see the Model Browser, simply right click on the designer surface as shown below:

Select the Model Browser menu option. You then see a new Model Browswer tab:

If you expand the Entity Types folder you get the following view:

Finally, if you want to navigate to a particular entity, simply right click the entity as shown below:

Select the Show In Browser menu option and the designer will navigate and select the corresponding entity:

Now we are back in business. It isn’t as easy as the Property selector but it still gets the job done. It certainly has made my life easier.

This took me a while to figure out. I am not sure why but we had this horrible workflow trying to update one or two entities without dropping the whole model when the property selector stopped working.

Hope this helps….

Advertisements
  1. Karl
    June 23, 2011 at 2:39 pm

    Matt,

    That is one complex data model. Nice work!

    Karl

    • June 23, 2011 at 2:46 pm

      Hey Karl, thanks man. Wish I could be out there for your Boise presentations!

  2. Wilson
    November 4, 2011 at 3:03 am

    Hey Matt, have experienced a performance issue because of the size of your model? how many entities do you have in your model?

    • November 4, 2011 at 12:18 pm

      Hi Wilson,

      Yes, we have experienced a lot of issues with models this size. I believe we have 200+ entities currently. At the time, we couldn’t break them out separately due to issues with WCF RIA Services and namespace collisions but I believe that has been fixed. As your model gets larger, you will see issues with performance. That is why you need to pre-compile your views.

      Thanks,

      Matt

  1. No trackbacks yet.

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

%d bloggers like this: