Agent skill

Entity Framework Core

by managedcode in managedcode/dotnet-skills

Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications.

MITAuto-check passedDatabases

Install Entity Framework Core

skills CLI
$ npx skills add managedcode/dotnet-skills --skill entity-framework-core -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install managedcode/dotnet-skills entity-framework-core --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/managedcode/dotnet-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/catalog/Frameworks/Entity-Framework-Core/skills/entity-framework-core .claude/skills/entity-framework-core && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
entity-framework-core
GitHub stars
486
Token cost
~2.3k tokens
SKILL.md length
403 words
Files
4 (incl. references)
Skills in repo
81
Repo updated
First seen
Licence
MIT

At a glance

Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications.

  • Works in 6 steps: Prefer EF Core for new development… → Keep DbContext lifetime scoped — align… → Review query translation — check… → …
  • Model configuration
  • SKILL.md covers Trigger On, Documentation, Workflow and Current Upstream Notes, plus 8 more sections
  • Calls dotnet

What it does

Entity Framework Core is an agent skill from managedcode/dotnet-skills. Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and EF6 migration decisions. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when…

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `manifest.json`, `references/anti-patterns.md` and `references/patterns.md`). Compatibility notes: Requires EF Core 7+ (preferably 8/9 for latest features).

It sits in Databases, covering ORMs and data access, Translation and Codebase knowledge for agents. It works with .NET. The repository describes itself as: Installable .NET skill catalog and CLI for Codex, Claude Code, GitHub Copilot, and Gemini. The licence is MIT.

When your agent uses it

  • Model configuration
  • EF6 migration decisions
  • : unrelated stacks
  • Generic tasks that do not need this specific guidance

Example prompts

  • “/entity-framework-core”

Requirements

  • Compatibility (from SKILL.md): Requires EF Core 7+ (preferably 8/9 for latest features).

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Prefer EF Core for new development unless a documented gap requires Dapper or raw SQL
  2. Keep DbContext lifetime scoped — align with unit of work
  3. Review query translation — check generated SQL, avoid N+1
  4. Treat migrations as first-class — reviewable, not throwaway
  5. Be deliberate about provider behavior — cross-provider but not identical
  6. Validate with query inspection — not just in-memory mental model

What it can do on your machine

Read from SKILL.md and the folder at commit 535dd55. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Requires EF Core 7+ (preferably 8/9 for latest features).

    From compatibility in the SKILL.md frontmatter.

Context cost

Entity Framework Core loads about 2.3k tokens when it runs, and up to ~7.8k if it reads all its reference files. Until then it costs about 140 tokens; SKILL.md has 403 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~140
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from managedcode/dotnet-skills at commit 535dd55, republished under its MIT licence (© managedcode). 403 words, ~2,307 tokens.

Download SKILL.mdSave it as .claude/skills/entity-framework-core/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
entity-framework-core
description
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and EF6 migration decisions. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
compatibility
Requires EF Core 7+ (preferably 8/9 for latest features).

Entity Framework Core

Trigger On

  • working on DbContext, migrations, model configuration, or EF queries
  • reviewing tracking, loading, performance, or transaction behavior
  • porting data access from EF6 or custom repositories to EF Core
  • optimizing slow database queries

Documentation

References
  • patterns.md - Query patterns, tracking strategies, loading strategies, projections, compiled queries, pagination, and temporal tables
  • anti-patterns.md - Common EF Core mistakes including N+1 queries, large contexts, generic repositories, and missing indexes

Workflow

  1. Prefer EF Core for new development unless a documented gap requires Dapper or raw SQL
  2. Keep DbContext lifetime scoped — align with unit of work
  3. Review query translation — check generated SQL, avoid N+1
  4. Treat migrations as first-class — reviewable, not throwaway
  5. Be deliberate about provider behavior — cross-provider but not identical
  6. Validate with query inspection — not just in-memory mental model

Current Upstream Notes

  • EF Core v10.0.11 is a servicing release. It fixes Azure SQL compatibility-level 170 JSON translation so nested OPENJSON projections retain AS JSON, and keeps EF compatible with .NET 11 MemoryExtensions.Min/Max overload additions. Re-run provider-backed JSON queries and compile against the repository's selected target framework after upgrading.
  • The August 2026 EF Core vs EF6 comparison remains the first stop for migration decisions. EF Core is the active cross-platform stack, but EF6-only EDMX/ObjectContext-heavy code should not move without a feature inventory and database-backed equivalence tests.

DbContext Patterns

Basic Configuration
csharp
public class AppDbContext : DbContext
{
    public DbSet<Product> Products => Set<Product>();
    public DbSet<Order> Orders => Set<Order>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
    }
}

// Entity Configuration (Fluent API)
public class ProductConfiguration : IEntityTypeConfiguration<Product>
{
    public void Configure(EntityTypeBuilder<Product> builder)
    {
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Name).HasMaxLength(200).IsRequired();
        builder.HasIndex(p => p.Sku).IsUnique();
        builder.HasMany(p => p.OrderItems).WithOne(oi => oi.Product);
    }
}
Registration with DI
csharp
builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(connectionString)
           .EnableSensitiveDataLogging()  // Dev only
           .EnableDetailedErrors());      // Dev only

// Or with pooling (better performance)
builder.Services.AddDbContextPool<AppDbContext>(options =>
    options.UseSqlServer(connectionString));

Query Patterns

Use AsNoTracking for Read-Only
csharp
// Bad - tracks entities unnecessarily
var products = await db.Products.ToListAsync();

// Good - no tracking overhead
var products = await db.Products
    .AsNoTracking()
    .ToListAsync();
Project to DTOs
csharp
// Bad - loads entire entity graph
var orders = await db.Orders
    .Include(o => o.Items)
    .Include(o => o.Customer)
    .ToListAsync();

// Good - loads only needed data
var orders = await db.Orders
    .Select(o => new OrderDto
    {
        Id = o.Id,
        CustomerName = o.Customer.Name,
        ItemCount = o.Items.Count,
        Total = o.Items.Sum(i => i.Price)
    })
    .ToListAsync();
Avoid N+1 Queries
csharp
// Bad - N+1 problem
foreach (var order in orders)
{
    var items = await db.OrderItems
        .Where(i => i.OrderId == order.Id)
        .ToListAsync();
}

// Good - eager loading
var orders = await db.Orders
    .Include(o => o.Items)
    .ToListAsync();

// Good - split query for large graphs
var orders = await db.Orders
    .Include(o => o.Items)
    .AsSplitQuery()
    .ToListAsync();
Compiled Queries (EF Core 9)
csharp
// Pre-compiled for frequently used queries
private static readonly Func<AppDbContext, int, Task<Product?>> GetProductById =
    EF.CompileAsyncQuery((AppDbContext db, int id) =>
        db.Products.FirstOrDefault(p => p.Id == id));

// Usage
var product = await GetProductById(db, productId);

Migration Patterns

Creating Migrations
bash
# Add migration
dotnet ef migrations add AddProductIndex

# Apply to database
dotnet ef database update

# Generate SQL script
dotnet ef migrations script --idempotent -o migrate.sql
Data Migrations
csharp
public partial class AddProductIndex : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.CreateIndex(
            name: "IX_Products_Sku",
            table: "Products",
            column: "Sku",
            unique: true);

        // Data migration (if needed)
        migrationBuilder.Sql(@"
            UPDATE Products
            SET NormalizedName = UPPER(Name)
            WHERE NormalizedName IS NULL");
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropIndex(
            name: "IX_Products_Sku",
            table: "Products");
    }
}
Show full SKILL.md (220 more words)Show less

Anti-Patterns to Avoid

Anti-PatternWhy It's BadBetter Approach
ToList() then filterLoads all data to memoryFilter in query
Multiple DbContext per requestTransaction issuesScoped lifetime
Lazy loading everywhereN+1 queriesExplicit Include
Generic repository wrapperRemoves query powerUse DbContext directly
Ignoring generated SQLHidden performance issuesLog and review
SaveChanges() in loopsMany roundtripsBatch then save

Performance Best Practices

  1. Index frequently queried columns:

    csharp
    builder.HasIndex(p => p.CreatedAt);
    builder.HasIndex(p => new { p.Category, p.Status });
  2. Use pagination:

    csharp
    var page = await db.Products
        .OrderBy(p => p.Id)
        .Skip(pageSize * pageNumber)
        .Take(pageSize)
        .ToListAsync();
  3. Batch updates (EF Core 7+):

    csharp
    await db.Products
        .Where(p => p.Category == "Obsolete")
        .ExecuteDeleteAsync();
    
    await db.Products
        .Where(p => p.Category == "Sale")
        .ExecuteUpdateAsync(p => p.SetProperty(x => x.Price, x => x.Price * 0.9m));
  4. Minimize network roundtrips:

    csharp
    // Bad - 3 roundtrips
    var product = await db.Products.FindAsync(id);
    var reviews = await db.Reviews.Where(r => r.ProductId == id).ToListAsync();
    var related = await db.Products.Where(p => p.Category == product.Category).ToListAsync();
    
    // Good - 1 roundtrip
    var data = await db.Products
        .Where(p => p.Id == id)
        .Select(p => new
        {
            Product = p,
            Reviews = p.Reviews,
            Related = db.Products.Where(r => r.Category == p.Category).Take(5)
        })
        .FirstOrDefaultAsync();

Concurrency Patterns

csharp
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }

    [ConcurrencyCheck]
    public int Version { get; set; }

    // Or use RowVersion
    [Timestamp]
    public byte[] RowVersion { get; set; }
}

// Handle concurrency conflicts
try
{
    await db.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException ex)
{
    var entry = ex.Entries.Single();
    var databaseValues = await entry.GetDatabaseValuesAsync();
    // Resolve conflict...
}

Deliver

  • EF Core models and queries that match the domain
  • safer migrations and lifetime management
  • performance-aware data access decisions
  • proper indexing and query optimization

Validate

  • query behavior is intentional (check SQL logs)
  • migrations are reviewable and correct
  • no N+1 queries in common paths
  • indexes exist for filtered/sorted columns
  • DbContext lifetime is scoped properly
  • concurrency is handled for critical entities

© managedcode, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in catalog/Frameworks/Entity-Framework-Core/skills/entity-framework-core of managedcode/dotnet-skills.

  • SKILL.md
  • manifest.json
  • references/anti-patterns.md
  • references/patterns.md

Open the folder on GitHubat commit 535dd55

Compare with similar skills

Entity Framework Core next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Entity Framework Core compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Entity Framework Core this skillmanagedcode/dotnet-skills486—~2.3kAutomated safety check: PassMIT
Content Write Blogprisma/web1.1k—~4.9kAutomated safety check: PassNone
Migrate Vstest To Mtprunceel/ReactiveProperty944—~4.3kAutomated safety check: PassMIT
Ef Corecodewithmukesh/dotnet-claude-kit7511 repos~2.3kAutomated safety check: PassMIT
Query Pipelinedotnet/efcore15k—~194Automated safety check: PassMIT
511 Frameworks Micronaut Jdbcjabrena/plinth445—~872Automated safety check: PassApache-2.0

Similar skills

  • Official

    A skill your agent uses when the operator wants to write a blog post, draft a blog article, start a new post for the Prisma blog, or publish to prisma.io/blog.

    1.1k GitHub stars~4.9k tokensUpdated today
    DatabasesAuto-check passed
  • Migrate Vstest To Mtp

    runceel/ReactiveProperty

    Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP).

    944 GitHub stars~4.3k tokensUpdated 1 mo ago
    DevOps & CloudAuto-check passed
  • Ef Core

    codewithmukesh/dotnet-claude-kit

    Entity Framework Core patterns for .NET 10. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~2.3k tokens
    DatabasesAuto-check passed
  • Query Pipeline

    dotnet/efcore

    Official

    Implementation details for EF Core LINQ query translation, SQL generation, and bulk operations (ExecuteUpdate/ExecuteDelete).

    15k GitHub stars~194 tokensUpdated today
    DatabasesAuto-check passed
  • A skill your agent uses when you need programmatic JDBC in Micronaut — pooled DataSource, parameterized SQL, io.micronaut.transaction.annotation.Transactional, batching, and domain exception…

    445 GitHub stars~872 tokensUpdated today
    DatabasesAuto-check passed
  • SQL To Business Logic

    nimrodfisher/data-analytics-skills

    Translate SQL queries into plain language business logic. An agent skill from nimrodfisher/data-analytics-skills.

    465 GitHub stars~636 tokensUpdated 12 days ago
    DatabasesAuto-check passed

More from managedcode/dotnet-skills

All 81 skills in this repo
  • Analyzer Config

    managedcode/dotnet-skills

    Use a repo-root .editorconfig to configure free .NET analyzer and style rules.

    486 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Archunitnet

    managedcode/dotnet-skills

    Use the open-source free ArchUnitNET library for architecture rules in .NET tests.

    486 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Aspire

    managedcode/dotnet-skills

    Build, upgrade, and operate Aspire 13.5.x C or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, MCP, and deployment patterns for…

    486 GitHub stars~3.6k tokensUpdated today
    Auto-check passed
  • Aspnet Core

    managedcode/dotnet-skills

    Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET.

    486 GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Asynkron Profiler

    managedcode/dotnet-skills

    Use the open-source free Asynkron.Profiler dotnet tool for CLI-first CPU, allocation, exception, contention, and heap profiling of .NET commands or existing trace artifacts.

    486 GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Azure Functions

    managedcode/dotnet-skills

    Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns.

    486 GitHub stars~2.6k tokensUpdated today
    Auto-check passed

Works with

Questions about Entity Framework Core

What does Entity Framework Core do?

Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. Entity Framework Core is an agent skill from managedcode/dotnet-skills.NET applications.

When should I use Entity Framework Core?

Entity Framework Core fits situations like: model configuration; EF6 migration decisions; : unrelated stacks; generic tasks that do not need this specific guidance.

How do I install Entity Framework Core in Claude Code?

Run `npx skills add managedcode/dotnet-skills --skill entity-framework-core -a claude-code`. Or copy the skill folder (catalog/Frameworks/Entity-Framework-Core/skills/entity-framework-core in managedcode/dotnet-skills) into .claude/skills/entity-framework-core in your project. Claude Code loads it when a task matches its description.

How do I install Entity Framework Core in Codex?

Run `npx skills add managedcode/dotnet-skills --skill entity-framework-core -a codex`. Or copy the skill folder (catalog/Frameworks/Entity-Framework-Core/skills/entity-framework-core in managedcode/dotnet-skills) into .agents/skills/entity-framework-core in your project. Codex loads it when a task matches its description.

Can I use Entity Framework Core in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add managedcode/dotnet-skills --skill entity-framework-core -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/entity-framework-core, .gemini/skills/entity-framework-core, .github/skills/entity-framework-core and .opencode/skills/entity-framework-core in your project.

What does Entity Framework Core need to run?

Going by SKILL.md and its folder, Entity Framework Core needs the command-line tools its instructions call (dotnet). Compatibility (from SKILL.md): Requires EF Core 7+ (preferably 8/9 for latest features)..

Does Entity Framework Core access the network?

SKILL.md names 1 domain. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.

Is Entity Framework Core safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Entity Framework Core use?

Entity Framework Core is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Entity Framework Core use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.5k tokens, read only when the agent opens those files.

What are the alternatives to Entity Framework Core?

Skills that share tags, products or a category with Entity Framework Core: Content Write Blog (prisma/web, 1.1k stars), Migrate Vstest To Mtp (runceel/ReactiveProperty, 944 stars), Ef Core (codewithmukesh/dotnet-claude-kit, 751 stars) and Query Pipeline (dotnet/efcore, 15k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Entity Framework Core?

managedcode (a GitHub organization) maintains it in managedcode/dotnet-skills, which has 486 GitHub stars. The repository holds 81 skills in this directory. The repository was last updated on October 7, 2026.

Source: managedcode/dotnet-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.