adapter-repository

Implement generic EF Core repositories with unit-of-work and Result<T> wrappers.

Updated Apr 19, 2026
One-click install
npx skills add https://github.com/lcmassena/AI_Skills --skill adapter-repository
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adapter-repository
Source: https://github.com/lcmassena/AI_Skills/tree/main/hexagonal-architect/adapter/repository
Command: npx skills add https://github.com/lcmassena/AI_Skills --skill adapter-repository

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a repository adapter pattern for EF Core, delivering a consistent data access layer that supports CRUD, paging, and transactional operations within a hexagonal architecture.

Core Features & Use Cases

  • Generic SqlRepository<T> base class with GetAsync, AddAsync, UpdateAsync, DeleteAsync, and GetPagedAsync.
  • Unit of Work integration via IUnitOfWork to coordinate commit/rollback across repositories.
  • EF Core DataContext mappings and entity configurations to enforce schema and validation.
  • Use Case: Build a robust persistence layer for domain-driven hexagonal applications and testability.

Quick Start

Register the DataContext and repository implementations in DI and start using the generic repository for basic CRUD against your entities.

Frequently Asked Questions about adapter-repository

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

FAQPage Schema
How do I implement a generic repository pattern with EF Core in a hexagonal architecture?

A generic repository pattern for EF Core provides a consistent data access layer for CRUD, paging, and transactional operations within hexagonal architecture. It uses a SqlRepository<T> base class to abstract persistence logic from the domain.

How does the unit of work pattern coordinate transactions across multiple EF Core repositories?

The unit of work pattern coordinates transactions via an IUnitOfWork interface to manage commit and rollback operations across multiple repositories. This ensures transactional consistency across SQL Server databases during complex domain operations.

Can I use EF Core repository patterns for C# applications requiring paged data access?

Yes, EF Core repository patterns support paged data access in C# applications through a GetPagedAsync method. This allows efficient querying of large datasets by returning subset results while maintaining transactional boundaries.

What is the benefit of returning Result<T> wrappers from repository data access operations?

Returning Result<T> wrappers from repository data access operations provides explicit error handling without throwing exceptions. It aligns with the IState<T> interface to reliably communicate success or failure states from CRUD queries.

Do I need dependency injection to register EF Core DataContext and repository implementations?

Yes, you need dependency injection to register the EF Core DataContext and generic repository implementations. Applying DI configuration connects the persistence layer to your domain-driven application for immediate use.

How do EF Core entity configurations and mappings enforce schema validation in a repository?

EF Core entity configurations and DataContext mappings enforce schema validation by applying constraints directly within the persistence layer. This guarantees data integrity before transactional commits are processed by the unit of work.