ef-core

Optimize Entity Framework Core LINQ queries and DbContext migration practices.

224|87|Updated Dec 15, 2018
One-click install
npx skills add https://github.com/Resgrid/Core --skill ef-core-resgrid
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ef-core
Source: https://github.com/Resgrid/Core/tree/main/.opencode/skills/ef-core
Command: npx skills add https://github.com/Resgrid/Core --skill ef-core-resgrid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps you build efficient, reliable data access layers with Entity Framework Core by reducing over-fetching, avoiding common performance traps, and making schema changes and bulk operations safer to manage.

Core Features & Use Cases

  • Lean, projection-based queries to avoid loading unnecessary entities and to reduce N+1 and over-fetching problems in LINQ.
  • Production-ready schema and change management using migrations as reviewed code, plus guidance for precision, indexes, and configuration separation via IEntityTypeConfiguration<T>.
  • High-performance data modifications with ExecuteUpdateAsync and ExecuteDeleteAsync, supported by interceptors for cross-cutting concerns like auditing and soft deletes.
  • Hot-path query optimization through compiled queries, with additional coverage for value converters and query filters.

Quick Start

Load the ef-core skill and ask for an EF Core query or DbContext/migration pattern recommendation tailored to your scenario, such as “Optimize this LINQ query to avoid N+1 and ensure it projects into DTOs.”

Frequently Asked Questions about ef-core

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

FAQPage Schema
How do I optimize EF Core LINQ queries to avoid N+1 and over-fetching?▼

To optimize EF Core LINQ queries and avoid N+1, use projection-first patterns to select only required columns into DTOs, preventing unnecessary entity loading. This approach eliminates over-fetching and ensures efficient query execution.

What is the best way to configure DbContext and migrations in EF Core?▼

The best way to configure DbContext and migrations is using IEntityTypeConfiguration for schema separation and treating migrations as reviewed code. This ensures production-ready change management with correct precision, indexes, and maintainable configuration.

How do I perform bulk updates and deletes efficiently with EF Core?▼

Perform efficient bulk updates and deletes in EF Core using ExecuteUpdateAsync and ExecuteDeleteAsync. These methods apply high-performance data modifications directly without loading entities into memory, and you can use interceptors for auditing or soft deletes.

When do I need compiled queries in EF Core hot paths?▼

You need compiled queries in EF Core when optimizing high-frequency read paths where query translation overhead impacts performance. This Skill provides guidance on implementing compiled queries alongside value converters and query filters for hot-path scenarios.

Can EF Core interceptors handle auditing and soft deletes automatically?▼

Yes, EF Core interceptors can handle auditing and soft deletes automatically by capturing cross-cutting concerns during data modifications. This Skill supports using interceptors alongside ExecuteUpdateAsync and ExecuteDeleteAsync for consistent enforcement.

Why should I use IEntityTypeConfiguration instead of fluent API in OnModelCreating?▼

You should use IEntityTypeConfiguration instead of fluent API in OnModelCreating to separate schema configuration into maintainable, testable classes. This prevents bloated DbContext definitions and enforces production-ready configuration practices for migrations.