Using multiple edmx file vs. one large edmx file?
Asked Answered
T

3

13

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.

Tonsure answered 26/1, 2011 at 3:33 Comment(1)
Your model should be about entities, not about tables.Jeopardize
A
16

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.

Abroach answered 21/11, 2012 at 16:43 Comment(0)
R
8

Having one big EDM containing all the entities generally is NOT a good practice and is not recommended. You should come up with different sets of domain models each containing related objects while each set is unrelated and disconnected from the other one.

Take a look at this post where I explained this matter in detail:
Does it make sense to create a single diagram for all entities?

Rager answered 26/1, 2011 at 14:20 Comment(0)
C
2

i think we should keep multiple edmx files in our project. it's like 1-edmx file -- one aggregate (collection of related objects). as per ddd (domain drive design) we can have more than one aggregates in our model. we can keep one edmx file for each aggregate

Capparidaceous answered 27/2, 2011 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.