5

Okay, so we have a solution that contains the following projects:

  • BusinessLogic
  • Entities
  • DataAccess
  • Utilities
  • UnitTests
  • UserInterface

It is a very large enterprise-level application. My question is, where do we put the entity framework? On one hand EF seems like a data access technology and should go in the DataAccess project. But then on the other hand it generates its own entities and those should be placed in our already large Entities project.

Which project is the better place for Entity Framework?

Is it possible to split up the entities from the persistence logic in EF?

Chev
  • 54,842
  • 60
  • 203
  • 309
  • Note that if you application is large enough you should be creating multiple edmx models. – tster Apr 05 '11 at 22:16
  • We are actually transitioning our data layer to a more modern one. We want to use EF. So starting out it will be just one EDMX, but we will add more as we slowly transition all our projects to use the new data layer. – Chev Apr 05 '11 at 22:40
  • 1
    how many entities are you talking about? I've run into model designer issues and metadata loading performance issues with more than 100 entities. – tster Apr 06 '11 at 11:02
  • This question is not about how many entities we have or how well it performs :) – Chev Apr 06 '11 at 13:50
  • yup, it's completely up to you. I'm just letting you know of what I ran in to in my experience with large applications and entity framework – tster Apr 06 '11 at 13:56

2 Answers2

7

Place EDMX file to DataAccess. Add T4 template for entities and move it from DataAccess to Entities (you will probably have to modify path to EDMX in the template). It will work - I'm using it all the time.

Edit:

Here is Walktrhough for POCOs but it should be same with STEs.

Ladislav Mrnka
  • 349,807
  • 56
  • 643
  • 654
  • Any links to help me in doing this? I have never heard of this before. – Chev Apr 05 '11 at 22:03
  • Would you mind providing me a small example of what you're doing? you make it sound so simple but all the resources I'm looking at are making it sound way more complicated. I have never used T4 Templates before. If you were willing to do a quick step by step I would be very appreciative. I know how to use EF, but this template thing is confusing me. – Chev Apr 05 '11 at 22:30
  • I thought that provided link is showing step by step example. Check it and ask concrete step which not clear. – Ladislav Mrnka Apr 06 '11 at 05:29
  • You said you are using it all the time. All I wanted was a sample of how *you* are doing it. – Chev Apr 06 '11 at 13:51
  • Finally a great example of how to seperate your entities into their own project (which everyone should be doing IMO) without creating a circular reference back to the data tier as I have seen before. +1 and thank you for that link. – Matt Feb 19 '13 at 16:13
0

I might be misunderstanding your question, but the thing I would suggest first off is to create a new project for your entity framework.

Is there a good reason for it to be in with the other projects? Keeping it separate keeps it small, and easier to manage. Also keeps the dependencies down.

peter
  • 11,559
  • 18
  • 75
  • 138
  • You are misunderstanding the question. EF needs to either go in our data access project, which contains code for accessing the database. Or it needs to go in our "Entities" project where we have defined all our custom entity objects. Eventually EF would replace these custom objects with its generated ones. – Chev Apr 06 '11 at 13:54
  • Didn't realise about the dependencies. – peter Apr 07 '11 at 23:07