Limits of Visual Studio 2012 and Entity Model generation: out-of-memory at around 3000 tables

Posted: (EET/GMT+2)

 

I was on Friday working with Dynamics AX 2012 and accessing data directly from it's SQL Server database. Dynamics AX is not a small piece of software; as a full-blown ERP solution, its database contains about 3,400 tables and numerous views and stored procedures, around 4,500 in total.

While I only needed to work with around 20–30 tables, I wanted to try what happens to Entity model generation, if all tables in the database are selected and the generation is run from within Visual Studio 2012. The interesting news: this fails with an "Out of memory" exception, and cannot be completed. While this limit is not about running out of physical RAM, it appears to be related to the fact that Visual Studio is a 32-bit application, and thus limited to about 1.8 GB of memory.

Now, I didn't go to the lengths of trying to find the exact number of tables when this error occurred, but in practice, this limit of around 3,000 tables is well enough. I wouldn't create an entity model with more than around 500 tables, but instead opt for multiple models divided by logical areas in the database. This way, there's no real limit on how many tables one can use in Entity model(s).

Oh, speaking of Entity Framework: you might be interested in learning what's being planned for Visual Studio 2013 and Entity Framework vNext. If so, check this blog post.