3

I'm trying to design an application, in ASP.NET MVC, using Enterprise Library 4.1 I added the Entity Framework POCO template and moved the generated entities to a separate "Entities" project. However, I'm having a hard time determining the best way to design this application. I'm assuming the ObjectContext should be in the same project as the EDMX file. But the ObjectContext has to have access to the POCOs. If I create repositories they would need to have access to both the POCOs and the ObjectContext. I'm assuming that the repository logic and the POCOs should be in the same project, but that wouldn't work because there would be a circular reference between the "POCOs project" and the "EDMX project." I don't want to put the ObjectContext in the "POCOs project" because that project shouldn't reference System.Data.

I've searched around for examples, but almost ever example I find throws the example together without the use of best practices. Maybe I'm making this too complicated. I'm just trying to understand how to best design applications.

Bob Wintemberg
  • 3,212
  • 6
  • 34
  • 44
  • possible duplicate of [Clean solution (project) structure with EF, Repositories, Entities](http://stackoverflow.com/questions/5283090/clean-solution-project-structure-with-ef-repositories-entities) – Ladislav Mrnka May 18 '11 at 07:07
  • @Ladislav Mrnka, I agree with you. Now that I see that question I believe mine is a duplicate. The only thing I would add is that I appreciate the input that @bkaid gave in his answer to my question. @bkaid it might be worth it to add you answer to the other question to have as a reference. – Bob Wintemberg May 18 '11 at 16:30

1 Answers1

7

If you are looking to use POCO's, you should look at Entity Framework Code First and skip the EDMX file altogether. Project Silk is a good example of this put out by Microsoft. I would do something slightly different but overall it covers EF4.1, POCOS, and repository pattern like you mentioned. Shrinkr is another good example project. A slightly smaller but still good example is EFMVC which mainly just focuses on the repository pattern with EF.

bkaid
  • 51,465
  • 22
  • 112
  • 128