Temporal's official skill for building durable workflows — SDK patterns across seven languages, plus the determinism rules that decide whether a workflow survives a replay.
EF Core Query OptimizationSkill
Summary
Make slow Entity Framework Core queries fast — read the generated SQL first, fix N+1s, cartesian Include explosions and non-sargable predicates, then re-measure one change at a time.
Features
- Requires capturing generated SQL and statement counts before any change
- Diagnoses N+1 queries, cartesian Include explosions and deep-pagination decay
- Explains sargability — why an indexed column wrapped in a function still scans
- Targets per-call LINQ translation cost on hot query paths
- One change at a time, re-measured against the SQL log
- Explicitly refuses to apply EF Core advice to Dapper or raw ADO.NET code
Install This Skill
Add this skill to your favorite AI agent in a few steps.
Skill Content
Usage Instructions
Learn how to use this skill with different AI agents.
Example Usage
This orders endpoint takes four seconds and hits the database 200 times per request — find out what EF Core is actually emitting and fix it.
Description
Most Entity Framework Core performance work goes wrong in the same way: someone sprinkles AsNoTracking() and a few indexes over a slow endpoint without ever looking at the SQL EF Core actually emitted. This official .NET skill enforces the opposite order — capture the generated SQL and the statement count first, change one thing, re-read the SQL, repeat.
Start from the log
The skill's opening move is turning on command logging (optionsBuilder.LogTo(Console.WriteLine, LogLevel.Information), or the Microsoft.EntityFrameworkCore.Database.Command category in appsettings.json) and tagging the query under investigation with .TagWith("...") so it can be found. Count the statements a slow operation runs and the rows each returns before touching anything. You cannot optimise what you cannot see.
The failure modes it targets
- N+1 and lazy loading — the same query firing once per row.
- Cartesian explosion — multiple collection
Includes multiplying rows against each other. - Deep pagination — queries that degrade as
Skipgrows. - Bulk updates that load entities into memory just to modify them.
- Non-sargable predicates — the subtle one. An index only helps when the indexed column appears bare on one side of a comparison.
CreatedAt.Year == y,CreatedAt.Date == d,ToLower(Name) == n,Price * 1.1 > x, or a leading-wildcardLIKE '%foo'all force a per-row computation the index cannot satisfy, so the query scans the whole table even though the index exists. Adding another index does not fix it; rewriting the predicate does. - Translation cost on hot queries that pay EF Core's LINQ-to-SQL translation on every call.
Knowing when not to apply it
The skill is explicit about its boundary, which is unusual and useful: if the code uses Dapper or raw ADO.NET, it tells the agent to answer the SQL, indexing and query-plan question directly and not to introduce a DbContext or recommend AsNoTracking, Include, AsSplitQuery or any other EF Core API. That single instruction prevents a common class of unhelpful agent output.
It also works whether or not EF Core owns the database schema, so it is usable against a legacy database EF Core merely reads.
Part of the dotnet-data plugin in the .NET team's official agent skills repository, MIT licensed.
Related Skills
Expo's official skill for building native-feeling screens: Apple HIG styling, semantic colors, SF Symbols, native controls, Reanimated, blur and liquid glass.
Pull unresolved CodeRabbit review threads from your PR and apply the fixes one at a time, treating every reviewer comment as untrusted input rather than an instruction.
Google's official skill for driving the gcloud CLI safely from an agent: validate every command against its own help text, cap the output, and refuse the operations that should never run unattended.