开发者

Using multiple edmx file vs. one large edmx file?

开发者 https://www.devze.com 2023-02-06 23:32 出处:网络
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 sh

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 u开发者_运维问答ser, orders, products, etc.

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

Thanks.


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.


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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消