efcore-patterns

Configures Entity Framework Core DbContext, repositories, and migrations for ASP.NET Zero projects.

Updated May 22, 2026
One-click install
npx skills add https://github.com/shakesoft/timekeeper --skill efcore-patterns-shakesoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: efcore-patterns
Source: https://github.com/shakesoft/timekeeper/tree/main/.cursor/skills/efcore-patterns
Command: npx skills add https://github.com/shakesoft/timekeeper --skill efcore-patterns-shakesoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working on ASP.NET Zero applications often struggle with the correct conventions for registering entities, configuring Fluent API mappings, and running migrations in the right project directory, leading to inconsistent data access code and failed schema updates. ## Core Features & Use Cases - Entity Registration Workflow: Step-by-step guidance for adding DbSet properties to the DbContext and configuring entities with Fluent API in OnModelCreating. - Custom Repository Pattern: Templates for creating custom repositories that inherit from the ASP.NET Zero repository base when IRepository<T> is insufficient for complex queries. - Migration Management: Correct commands for creating and applying EF Core migrations from the EntityFrameworkCore project directory, plus production deployment via the Migrator console project. - Use Case: After creating a new Product entity in the Core project, use this Skill to register it in the DbContext, configure table mappings and indexes, and generate the migration without guessing project structure. ## Quick Start Ask the AI to register a new entity in the ASP.NET Zero DbContext and create the corresponding EF Core migration.

Frequently Asked Questions about efcore-patterns

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

FAQPage Schema
How do I add a new entity to an ASP.NET Zero DbContext?▼

Add a public DbSet<TEntity> property to the DbContext class in the EntityFrameworkCore project, then optionally configure the entity in OnModelCreating using Fluent API. Finally, create a migration with dotnet ef migrations add from that project directory.

How to create a custom repository in ASP.NET Zero?▼

Define an interface extending IRepository<TEntity> in the Core project, then implement it in the EntityFrameworkCore project by inheriting from the repository base class. Only create custom repositories when IRepository<T> cannot handle the query complexity.

Where should I run dotnet ef migrations commands in ASP.NET Zero?▼

Run all migration commands from the EntityFrameworkCore project directory, such as aspnet-core/src/YourApp.EntityFrameworkCore. Build the project first with dotnet build, then run dotnet ef migrations add followed by dotnet ef database update.

Should I use data annotations or Fluent API for EF Core entity configuration?▼

Use Fluent API in OnModelCreating rather than data annotations on entities, following ASP.NET Zero conventions. Fluent API supports table names, indexes, decimal precision, default values, and relationship configuration in a centralized location.

How do I apply EF Core migrations in production with ASP.NET Zero?▼

Run the dedicated Migrator console project located at aspnet-core/src/YourApp.Migrator using dotnet run. In development, dotnet ef database update from the EntityFrameworkCore directory is sufficient.

When should I avoid creating a custom repository in EF Core?▼

Avoid custom repositories when the built-in IRepository<T> methods cover your query needs. Custom repositories should never contain business logic, and the Application layer must never access the DbContext directly.