How should I implement the repository pattern for complex object models?

Posted by Eric Falsken on Programmers See other posts from Programmers or by Eric Falsken
Published on 2012-10-16T17:43:05Z Indexed on 2012/10/16 23:20 UTC
Read the original article Hit count: 150

Our data model has almost 200 classes that can be separated out into about a dozen functional areas. It would have been nice to use domains, but the separation isn't that clean and we can't change it.

We're redesigning our DAL to use Entity Framework and most of the recommendations that I've seen suggest using a Repository pattern. However, none of the samples really deal with complex object models. Some implementations that I've found suggest the use of a repository-per-entity. This seems ridiculous and un-maintainable for large, complex models.

Is it really necessary to create a UnitOfWork for each operation, and a Repository for each entity? I could end up with thousands of classes. I know this is unreasonable, but I've found very little guidance implementing Repository, Unit Of Work, and Entity Framework over complex models and realistic business applications.

© Programmers or respective owner

Related posts about asp.net-mvc

Related posts about entity-framework