Using multiple edmx file vs. one large edmx file?

Or A picture Or A · Jan 26, 2011 · Viewed 14.2k times · Source

I'm new to the Entity model thing and i'm looking for an advise how to organize my Entity model.

should i create one entity model file (.edmx) which will contain all the tables in my database or should i break it logical files for user, orders, products, etc.

Please let me know which one is better and what the pros/cons (if any) of each alternative.

Thanks.

Answer

Mindstorm Interactive picture Mindstorm Interactive · Nov 21, 2012

I'm going to go against the grain here. I've built 2 large applications with EF now, one with a single edmx and one with several. There are pros and cons but generally I found life to be much easier with one edmx. The reason is that there is almost never a real separation of domains within an app, even if there appears to be from the start. New requirements pop up asking you to relate entities in different edmx's then you have to refactor and continually move things around.

All arguments for dividing will soon be obsolete when EF 5 introduces Multiple Diagrams, which is the only real benefit for dividing edmx files in the first place. You don't want to have to see everything you're not working on and you don't want a performance impact.

In my app with the divided edmx's we now have some duplicate entities to get the benefit of navigation properties. Maybe your app has a true separation of domains, but usually everything connects to the user. I'm considering merging two of the now but it will be a lot of work. So I would say keep them together until it becomes a problem.