Where to place the entity framework in our solution?
N

2

6

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?

Nolasco answered 5/4, 2011 at 21:51 Comment(5)
Note that if you application is large enough you should be creating multiple edmx models.Matador
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.Nolasco
how many entities are you talking about? I've run into model designer issues and metadata loading performance issues with more than 100 entities.Matador
This question is not about how many entities we have or how well it performs :)Nolasco
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 frameworkMatador
M
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.

Madeleinemadelena answered 5/4, 2011 at 21:56 Comment(6)
Any links to help me in doing this? I have never heard of this before.Nolasco
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.Nolasco
I thought that provided link is showing step by step example. Check it and ask concrete step which not clear.Madeleinemadelena
You said you are using it all the time. All I wanted was a sample of how you are doing it.Nolasco
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.Brescia
The link is dead. Instead see #5566133Unfamiliar
T
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.

Thrust answered 6/4, 2011 at 4:57 Comment(2)
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.Nolasco
Didn't realise about the dependencies.Thrust

© 2022 - 2024 — McMap. All rights reserved.