optimizing-ef-core-queries

optimizing-ef-core-queries is a skill for Claude Code, Codex from managedcode/dotnet-skills. It costs 116 tokens per session (4,928 once invoked), scanned A, a copy of optimizing-ef-core-queries, MIT.

A guide to finding and fixing slow Entity Framework Core database queries. EF Core is a .NET tool that turns C# queries into database commands.

In plain words
What is it for?
Use it to inspect generated SQL, reduce N+1 queries and round-trips, improve paging and bulk updates, and measure whether a query change helped.
Why use it?
It helps identify excessive SQL, repeated database calls, duplicated rows, missing indexes, slow pagination, and other causes of poor query performance.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to inspect generated SQL, reduce N+1 queries and round-trips, improve paging and bulk updates, and measure whether a query change helped.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/managedcode/dotnet-skills/optimizing-ef-core-queries
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.

Any agent
npx skills add managedcode/dotnet-skills --skill optimizing-ef-core-queries
Clone the repo
git clone --depth 1 https://github.com/managedcode/dotnet-skills

Made for: Claude Code, Codex.

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 optimizing-ef-core-queries

README.md
[![agentmods](https://agentmods.dev/badge/skills/managedcode/dotnet-skills/optimizing-ef-core-queries/github.svg)](https://agentmods.dev/skills/managedcode/dotnet-skills/optimizing-ef-core-queries)
Your own site
<a href="https://agentmods.dev/skills/managedcode/dotnet-skills/optimizing-ef-core-queries"><img src="https://agentmods.dev/badge/skills/managedcode/dotnet-skills/optimizing-ef-core-queries/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for optimizing-ef-core-queries

Your own site · 80×15
<a href="https://agentmods.dev/skills/managedcode/dotnet-skills/optimizing-ef-core-queries"><img src="https://agentmods.dev/badge/skills/managedcode/dotnet-skills/optimizing-ef-core-queries.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 116 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,928 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod 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.00116 $0.04928
Opus 5.5 $0.00046 $0.01971
Sonnet 5.5 $0.00023 $0.00986
Haiku 4.5 $0.00012 $0.00493

Measured 1mo ago against content hash a4c0d87d624f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

optimizing-ef-core-queries 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 1mo 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.

Origin

This is a copy

100% identical to optimizing-ef-core-queries — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

catalog/Libraries/Official-DotNet-Data/skills/optimizing-ef-core-queries/SKILL.md · 282 lines

How it starts

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

Optimizing EF Core Queries

Diagnose and fix slow or incorrect application data access built on EF Core. In a source-only review, trace the code without executing it and separate proven code behavior from runtime assumptions. When SQL, logs, or plans are available, use them to confirm the bottleneck. Prefer changes that reduce round-trips, duplicated rows, scans, or per-call translation cost over micro-optimizations.

When to Use

  • EF Core queries are slow or emit far more SQL statements than expected
  • The same query repeats once per row (N+1 / lazy loading)
  • Multiple collection Includes blow up or duplicate rows
  • Deep pages slow down as Skip grows, or bulk updates load rows just to modify them
  • A filtered/sorted query scans even though the column is indexed, or a filtered/sorted column has no supporting index
  • A hot, frequently-executed query pays EF Core's LINQ-translation cost on every call

When Not to Use

  • The code uses Dapper or raw ADO.NET, not EF Core. Answer the SQL/indexing/query-plan question directly; do not introduce a DbContext or recommend AsNoTracking, Include, AsSplitQuery, or other EF Core APIs.

Source review workflow

  1. Find the EF boundary: DbContext, DbSet, repository implementation, unit of work, query helper, or model-building code. Follow the implementation rather than assuming what an interface method does.
  2. Trace each query to execution or enumeration. Check whether operators bind to Queryable or Enumerable, including inside helpers; an IEnumerable can remain a deferred database sequence.
  3. Count database operations and actual transaction boundaries along the calling path, including immediate writes and repeated enumeration. Also track which operations share the same DbContext instance
  4. For every execution path, independently inspect predicates, expression construction, projection contents, result bounds, ordering, Includes, tracking, SQL parameterization, and model-building code.
  5. Preserve the contract: result membership and order, random-page access, generated keys, retries, transaction and partial-failure behavior, concurrency handling, and domain/interceptor side effects.
  6. Report prioritized findings with locations, the affected call path, concrete impact, and a safe remedy. Briefly identify sound counterparts and state what was not validated. Do not equate source reasoning with measured plans or speedups.

Read the full file on GitHub · 282 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 1mo ago Changed · +122 lines · +30 tokens per session a4c0d87d624f
  2. 2mo ago First seen · 160 lines · 86 tokens per session scan A 674fe2a77386

Subscribe to this mod's changes

optimizing-ef-core-queries is a skill published in the GitHub repository managedcode/dotnet-skills (527 stars, last pushed 16d ago), licensed MIT. It adds 116 tokens to every session and 4,928 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to optimizing-ef-core-queries, differing in 0 lines, and is treated as a copy.

Related

optimizing-ef-core-queries compared with skills from other repositories

optimizing-ef-core-queries next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
optimizing-ef-core-queriesmanagedcode/dotnet-skillsSkill52716d agoMITA116Claude Code, Codex
agent-bom-troubleshootLeoYeAI/openclaw-master-skillsSkill2.2k8d agoMITA53Claude Code, Codex
windbg-diagnostic-methodmicrosoft/win-dev-skillsSkill52113d agoMITA42Claude Code
windbg-kernel-bugcheck-triagemicrosoft/win-dev-skillsSkill52113d agoMITA50Claude Code
windbg-user-exception-triagemicrosoft/win-dev-skillsSkill52113d agoMITA69Claude Code
windbg-user-heap-corruption-investigationmicrosoft/win-dev-skillsSkill52113d agoMITA46Claude Code
windbg-user-virtual-memory-exhaustionmicrosoft/win-dev-skillsSkill52113d agoMITA54Claude Code