ef-core-patterns

ef-core-patterns is a skill for Claude Code, Codex from zdanovichnick/dotnet-pilot. It costs 24 tokens per session (543 once invoked), scanned A, original, MIT.

A reference guide for Entity Framework Core, a .NET tool that maps application code to database tables. It covers safer database changes, query tuning, setup patterns, and common mistakes.

In plain words
What is it for?
Use it when planning database migrations, adding or changing tables and columns, configuring models, optimizing queries, or checking EF Core code for risky patterns.
Why use it?
It helps developers avoid losing data, breaking existing rows, or writing database queries that run poorly. It also provides consistent guidance for configuring EF Core.

Skill for Claude CodeCodex

Part of the dotnet-pilot plugin — 16 skills, 15 agents, 3 hooks, 1 MCP server shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zdanovichnick/dotnet-pilot/ef-core-patterns
Any agent
npx skills add zdanovichnick/dotnet-pilot --skill ef-core-patterns
Clone the repo
git clone --depth 1 https://github.com/zdanovichnick/dotnet-pilot

Made for: Claude Code, Codex.

Or install dotnet-pilot, the plugin that ships this one along with the rest of its 16 skills, 15 agents, 3 hooks, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ef-core-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/zdanovichnick/dotnet-pilot/ef-core-patterns.svg)](https://agentmods.dev/skills/zdanovichnick/dotnet-pilot/ef-core-patterns)
Your own site
<a href="https://agentmods.dev/skills/zdanovichnick/dotnet-pilot/ef-core-patterns"><img src="https://agentmods.dev/badge/skills/zdanovichnick/dotnet-pilot/ef-core-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 543 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00024 $0.00543
Opus 5 $0.00012 $0.00271
Sonnet 5 $0.00005 $0.00109
Haiku 4.5 $0.00002 $0.00054

Measured 5d ago against content hash 0ab7f2c851e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

ef-core-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ef-core-patterns/SKILL.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

EF Core Patterns

Reference material for EF Core development. Used by dnp-ef-migration-planner and dnp-planner.

Migration Safety

Safe Operations

  • Adding a new table
  • Adding a nullable column
  • Adding a column with a default value
  • Adding an index
  • Renaming (with migrationBuilder.RenameColumn — preserves data)

Dangerous Operations (require confirmation)

  • Dropping a column (data loss)
  • Changing column type (potential data truncation)
  • Adding NOT NULL column without default (fails on existing rows)
  • Dropping a table (data loss)
  • Removing an index (performance impact)

Migration Best Practices

  • One migration per logical change
  • Never edit generated migration files manually
  • Always test with --dry-run before applying
  • Keep migrations small and reversible
  • Use migrationBuilder.Sql() for data migrations, not EF operations

Configuration Patterns

Fluent API (preferred)

public class UserConfiguration : IEntityTypeConfiguration<User>
{
    public void Configure(EntityTypeBuilder<User> builder)
    {
        builder.HasKey(u => u.Id);
        builder.Property(u => u.Email).HasMaxLength(256).IsRequired();
        builder.HasIndex(u => u.Email).IsUnique();
        builder.HasMany(u => u.Orders).WithOne(o => o.User).HasForeignKey(o => o.UserId);
    }
}

DbContext Registration

// In OnModelCreating:
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);

Query Optimization

Do

  • Use AsNoTracking() for read-only queries
  • Use projections (Select) to fetch only needed columns
  • Use Include with ThenInclude for eager loading (avoid N+1)
  • Use split queries for many includes: .AsSplitQuery()
  • Use ExecuteUpdateAsync / ExecuteDeleteAsync for bulk operations (EF 7+)

Don't

  • Don't call ToList() before filtering (materializes entire table)
  • Don't use Count() when you need Any()
  • Don't load navigation properties you don't need
  • Don't use FromSqlRaw with string interpolation (SQL injection risk)
  • Don't forget CancellationToken on async queries

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 74 lines · 24 tokens per session scan A 0ab7f2c851e7

Subscribe to this mod's changes

ef-core-patterns is a skill published in the GitHub repository zdanovichnick/dotnet-pilot (4 stars, last pushed 9d ago), licensed MIT. It adds 24 tokens to every session and 543 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

azure-resource-manager-postgresql-dotnet

Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for…

microsoft/skills · 97 tokens

entity-design

Design EF Core entities with navigation properties, value objects, Fluent API configuration, and audit fields. Use when creating new database entities, adding relationships, configuring owned types, designing a domain model for Entity Framework Core, or setting up table-per-hierarchy inheritance.

andresharpe/dotbot · 54 tokens

create-migration

Create and manage Entity Framework Core database migrations including schema changes, seed data, and rollback strategies. Use when adding or modifying EF Core entities, setting up a new DbContext, applying data seeding, running dotnet ef commands, or troubleshooting migration conflicts.

andresharpe/dotbot · 55 tokens

add-migration

Use when an EF Core model change needs a migration, or when a migration has to be reviewed as SQL before it is committed.

Krzysztof318/MailFathom · 30 tokens

update-dependencies

Use when the task in front of you is to move dependency pins — packages in either stack, Rust crates, tools, SDKs, GitHub Action references, or container images — or to find out which of them are behind and whether any changed licence.

Krzysztof318/MailFathom · 55 tokens

creating-oracle-to-postgres-master-migration-plan

Discovers all projects in a .NET solution, classifies each for Oracle-to-PostgreSQL migration eligibility, and produces a persistent master migration plan. Use when starting a multi-project Oracle-to-PostgreSQL migration, creating a migration inventory, or assessing which .NET projects contain Oracle dependencies.

boshi-xixixi/TraeSkill · 71 tokens