repository-pattern

Implement EF Core repository patterns for aggregate roots with Unit of Work.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/hiiamsky/multi-agent-dev-team --skill repository-pattern-hiiamsky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: repository-pattern
Source: https://github.com/hiiamsky/multi-agent-dev-team/tree/main/.github/skills/dotnet-repository-pattern
Command: npx skills add https://github.com/hiiamsky/multi-agent-dev-team --skill repository-pattern-hiiamsky

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generates Repository interfaces and implementations following the Repository pattern to provide a clean data-access boundary around aggregate roots using EF Core.

Core Features & Use Cases

  • Interface in Domain layer defines the contract for aggregate root data access.
  • Implementation in Infrastructure uses EF Core to perform CRUD and queries.
  • Unit of Work integration enables coordinated SaveChanges across repositories.
  • Supports per-aggregate repository structure and optional specifications for advanced filtering.

Quick Start

Generate domain interfaces and infrastructure implementations for an aggregate root and register them with the DI container.

Frequently Asked Questions about repository-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement the repository pattern for aggregate roots using EF Core?

The repository pattern for aggregate roots using EF Core is implemented by defining data access interfaces in the Domain layer and concrete implementations in the Infrastructure layer. This abstracts data access and provides a clean boundary around aggregate roots.

Does the repository pattern work with Unit of Work for EF Core?

Yes, the repository pattern works with Unit of Work for EF Core by enabling coordinated SaveChanges across multiple repositories. The implementation ensures repositories contain no SaveChanges calls, delegating that responsibility to the Unit of Work.

How do I register EF Core repositories with dependency injection?

Registering EF Core repositories with dependency injection involves providing interface definitions and concrete implementations to the DI container. The pattern includes DI registration support to wire up domain interfaces with their infrastructure implementations.

Can I use specifications for complex queries with the repository pattern?

Yes, you can use specifications for complex queries with the repository pattern. The implementation supports optional specifications for advanced filtering, allowing you to encapsulate query logic and apply it across aggregate root repositories.

Why should repositories not call SaveChanges in EF Core?

Repositories should not call SaveChanges in EF Core to maintain a coordinated data persistence boundary. By omitting SaveChanges calls, the repository pattern delegates transaction control to the Unit of Work, ensuring atomic saves across multiple aggregate roots.

Do I need CancellationToken support for EF Core repository implementations?

Yes, you need CancellationToken support for EF Core repository implementations to allow cooperative cancellation of data access operations. The generated repository pattern ensures CancellationToken is supported throughout its interface definitions and concrete implementations.