Books in a library

In Defense of the Repository: Constrained, Specification-Driven, and Tunable

Many, dare I say most, .NET developers argue against the Repository Pattern when using Entity Framework Core (EF Core). A DbContext is already a unit of work. A DbSet<T> is already an IQueryable<T>, which is already a repository and a specification mechanism rolled into one, courtesy of LINQ. That’s the honest, strong version of the argument against adding a repository layer on top of EF Core, and the people making it aren’t wrong about the common failure mode: a repository with GetAll(), a dozen near-duplicate GetByXAsync() methods, or one that just hands back IQueryable<T> and calls it abstraction. That kind of repository adds a file; it doesn’t do anything a plain DbSet doesn’t already do. ...

November 17, 2026 · 29 min