Is there a reason for using the Repository pattern with Entity Framework if I know I will only ever use EF?

后端 未结 5 1284
离开以前
离开以前 2020-12-30 01:56

From reading various books and articles, I seem to rather often find the usage of the Repository-pattern suggested. I get the point if you need to be able to swap out your d

5条回答
  •  盖世英雄少女心
    2020-12-30 02:11

    What people don't realize is that EF is already an Repository and Unit-of-Work.

    Repository has become an anti-pattern because the criteria of its usage was never met in the first place. Never use a design pattern because its cool or trendy or trying to build your resume, in fact this should be a standard rule for all design patterns.

    Only build a Repository and Unit-of-Work on top of EF if your application is

    • very large (lasagna layer)
    • long-lived (10 years or so)
    • has more than 5 developers working in parallel
    • has developers that are separated geographically
    • requires a lot of maintenance
    • multiple data access infrastructures

    A good indication is when upgrading from EF5 to EF6 requires you to knock on everybody's door.

提交回复
热议问题