Source profileQuality 94/100

Postpartum-genushyacinthus29/dotnet-skills/skills/dotnet-entity-framework-core/SKILL.md

dotnet-entity-framework-core

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

Source repository stars
9
Declared platforms
0
Static risk flags
0
Last source update
2026-08-23
Source checked
2026-08-25

Decision brief

What it does: where it fits

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

Best for

    Not for

    • Tasks that require unconfirmed production actions or broad system permissions.
    • Environments where the pinned source and install steps cannot be inspected.

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/Postpartum-genushyacinthus29/dotnet-skills --skill "skills/dotnet-entity-framework-core"
    Safe inspection promptEditorial

    Inspect the Agent Skill "dotnet-entity-framework-core" from https://github.com/Postpartum-genushyacinthus29/dotnet-skills/blob/f9c1a213bc25d95641adc3a59f8048cb5656741c/skills/dotnet-entity-framework-core/SKILL.md at commit f9c1a213bc25d95641adc3a59f8048cb5656741c. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      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…

      Prefer EF Core for new development unless a documented gap requires Dapper or raw SQLKeep DbContext lifetime scoped — align with unit of workReview query translation — check generated SQL, avoid N+1
    2. 02

      Trigger On

      working on DbContext, migrations, model configuration, or EF queries

      working on DbContext, migrations, model configuration, or EF queriesreviewing tracking, loading, performance, or transaction behaviorporting data access from EF6 or custom repositories to EF Core
    3. 03

      Documentation

      EF Core Overview

      EF Core OverviewPerformanceEfficient Querying
    4. 04

      DbContext Patterns

      Review the “DbContext Patterns” section in the pinned source before continuing.

      Review and apply the “DbContext Patterns” source section.
    5. 05

      Basic Configuration

      Review the “Basic Configuration” section in the pinned source before continuing.

      Review and apply the “Basic Configuration” source section.

    Permission review

    Static risk signals and limitations

    No configured static risk pattern was detected

    This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score94/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars9SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    Postpartum-genushyacinthus29/dotnet-skills
    Skill path
    skills/dotnet-entity-framework-core/SKILL.md
    Commit
    f9c1a213bc25d95641adc3a59f8048cb5656741c
    License
    MIT
    Collected
    2026-08-25
    Default branch
    main
    View the original SKILL.md

    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

    DbContext Patterns

    Basic Configuration

    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

    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

    // Bad - tracks entities unnecessarily
    var products = await db.Products.ToListAsync();
    
    // Good - no tracking overhead
    var products = await db.Products
        .AsNoTracking()
        .ToListAsync();
    

    Project to DTOs

    // 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

    // 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)

    // 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

    # 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

    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");
        }
    }
    

    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:

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

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

      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:

      // 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

    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

    Frequently asked questions

    What to verify before installation and use

    What does the dotnet-entity-framework-core source document cover?

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

    How do I install dotnet-entity-framework-core?

    The source record exposes this install command: npx skills add https://github.com/Postpartum-genushyacinthus29/dotnet-skills --skill "skills/dotnet-entity-framework-core". Inspect the command and pinned source before running it.

    Alternatives

    Compare before choosing

    Computed 96156

    open-edge-platform/edge-ai-libraries

    chatqna-helm-deploy

    Deploy Chat Question-and-Answer Core to Kubernetes using Helm (OpenVINO CPU, OpenVINO GPU, or Ollama), including values.yaml configuration, helm install/upgrade, deployment verification, uninstall, and translation from Docker Compose setup_env.sh variables into Helm override values. Use this skill when the user says "deploy chatqna core to kubernetes", "helm install chatqna-core", "configure values.yaml", "convert compose config to helm", or "translate setup_env.sh to chart values".

    Computed 9439,098

    wshobson/agents

    brand-landingpage

    Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens —

    Computed 931,248

    first-fluke/oh-my-agent

    oma-translation

    Context-aware translation that preserves tone, style, and natural word order. Use when translating UI strings, documentation, marketing copy, or any multilingual content. Infers register, domain, and style from the source text and surrounding codebase context.

    Computed 921,248

    first-fluke/oh-my-agent

    oma-translation

    Context-aware translation that preserves tone, style, and natural word order. Use when translating UI strings, documentation, marketing copy, or any multilingual content. Infers register, domain, and style from the source text and surrounding codebase context.