dotnet / dotnet/docs

Mis-use of Repository pattern

Open
#36,632 0 comments 8 reactions 0 assignees View on GitHub
:watch: Not Triaged dotnet-architecture/svc microservices/subsvc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

Hi.
Based on the most formal definition and description of the Repository pattern in [Martin Fowler's "Patterns of Enterprise Application Architecture" (Addison Wesley, 2003)](https://www.google.com/books/edition/Patterns_of_Enterprise_Application_Archi/FyWZt5DdvFkC?hl=en), it would be better to use the term "Wrapper/Adapter" pattern instead of "Repository".
The true "Repository" is a mediator, and its duty is just fetching data, not persisting.
However, your version is merely a wrapper around a complex composite class (EF DbContext) that acts as a facade behind the scenes.
Many computer science students and software developers are misguided by this documentation because Microsoft is a giant tech company, and they believe every word of Microsoft documentation as if it were told by God.

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: 8be69079-b229-819b-0408-fb6c6aa30b88
* Version Independent ID: 3657bdb9-00c1-bb97-3470-d4f8c7569676
* Content: [Implementing the infrastructure persistence layer with Entity Framework Core](https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/infrastructure-persistence-layer-implementation-entity-framework-core#implement-custom-repositories-with-entity-framework-core)
* Content Source: [docs/architecture/microservices/microservice-ddd-cqrs-patterns/infrastructure-persistence-layer-implementation-entity-framework-core.md](https://github.com/dotnet/docs/blob/main/docs/architecture/microservices/microservice-ddd-cqrs-patterns/infrastructure-persistence-layer-implementation-entity-framework-core.md)
* Product: **dotnet-architecture**
* Technology: **microservices**
* GitHub Login: @jamesmontemagno
* Microsoft Alias: **jamont**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.