DB Migrations
kurealnum/dotfiles
A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…
Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster.
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install dotnet/skills optimizing-ef-core-queries --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .claude/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.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/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .claude/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queriesType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install dotnet/skills optimizing-ef-core-queries --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .agents/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .agents/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install dotnet/skills optimizing-ef-core-queries --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .cursor/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .cursor/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/dotnet/skills.git --path plugins/dotnet-data/skills/optimizing-ef-core-queries--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install dotnet/skills optimizing-ef-core-queries --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .gemini/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .gemini/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install dotnet/skills optimizing-ef-core-queriesInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .github/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .github/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add dotnet/skills --skill optimizing-ef-core-queries -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install dotnet/skills optimizing-ef-core-queries --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/plugins/dotnet-data/skills/optimizing-ef-core-queries .opencode/skills/optimizing-ef-core-queries && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "optimizing-ef-core-queries" agent skill from https://github.com/dotnet/skills/tree/main/plugins/dotnet-data/skills/optimizing-ef-core-queries into .opencode/skills/optimizing-ef-core-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-ef-core-queries", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
optimizing-ef-core-queriesOptimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster.
Optimizing Ef Core Queries is an agent skill from dotnet/skills, published by the product's own GitHub organization. Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.
Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Databases, covering SQL, ORMs and data access and Database schema design. It works with SQL. The repository describes itself as: Repository for skills to assist AI coding agents with .NET and C. The licence is MIT.
Read from SKILL.md and the folder at commit a660de8. It shows what the files ask for, not the result of running them.
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.
Shell commands in SKILL.md call:
dotnetFrom the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
learn.microsoft.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Optimizing Ef Core Queries loads about 2.7k tokens when it runs. Until then it costs about 97 tokens; SKILL.md has 1,286 words of instructions outside code blocks.
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.
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.
The full file from dotnet/skills at commit a660de8, republished under its MIT licence (© dotnet). 1,286 words, ~2,729 tokens.
.claude/skills/optimizing-ef-core-queries/SKILL.md (or your agent's skills folder).Diagnose and fix slow Entity Framework Core (EF Core) queries. Start from the generated SQL/logs, apply the smallest change that removes the bottleneck, and confirm the fix by re-reading the SQL and the query count. Prefer changes that reduce round-trips, duplicated rows, scans, or per-call translation cost over micro-optimizations. Apply one change at a time and re-measure.
Includes blow up or duplicate rowsSkip grows, or bulk updates load rows just to modify themDbContext or recommend AsNoTracking, Include, AsSplitQuery, or other EF Core APIs.You cannot optimize what you cannot see. Turn on command logging and read the SQL and query count before changing anything:
optionsBuilder.LogTo(Console.WriteLine, LogLevel.Information);
// or set "Microsoft.EntityFrameworkCore.Database.Command": "Information" in appsettings.jsonTag a query with .TagWith("...") to find it in the log. Count how many statements a slow operation runs, and how many rows each returns, before and after each change.
An index can only be used when the indexed column appears bare on one side of the comparison. Wrapping it in a function or arithmetic — CreatedAt.Year == y, CreatedAt.Date == d, ToLower(Name) == n, Price * 1.1 > x, or a leading-wildcard LIKE '%foo' — forces a per-row computation the index cannot satisfy, so the query scans the whole table even though the index exists. Adding another index changes nothing. Rewrite the predicate so the column stays bare, usually as a half-open range:
// Non-sargable: a function is computed for every row → full scan
db.Logs.Where(l => l.CreatedAt.Year == year);
// Sargable: bare column compared to constants → index seek
var start = new DateTime(year, 1, 1);
db.Logs.Where(l => l.CreatedAt >= start && l.CreatedAt < start.AddYears(1));The same rule covers several common shapes:
ToLower(...)/ToUpper(...).column * k > x.column.ToString() (for example matching the text form of a number or date, total.ToString().StartsWith(p)) applies a function to every row and often can't be translated to SQL at all, forcing a client-side evaluation that pulls the whole table into memory. Filter on the typed column with a real comparison or range instead.name.Contains(term) becomes an unanchored LIKE '%term%' that can't seek an index and scans the table; a trailing-wildcard prefix (name.StartsWith(term) → 'term%') can seek. Anchor the search when a prefix match is acceptable — this changes which rows match, so confirm the behavior first — and put real substring or fuzzy search behind a full-text index on large tables.Verify: the plan shows a seek/index instead of a scan and duration drops. If the column genuinely has no index, add one (see below) — but only after the predicate is sargable.
On a very hot path that runs the same query shape thousands of times over a reused context, EF Core re-parses the LINQ expression tree and probes its query cache on every call. When the query is already minimal (an indexed lookup or a small projection) and read-only tweaks such as AsNoTracking buy nothing, that per-call translation is the remaining cost. Compile the query once with EF.CompileQuery / EF.CompileAsyncQuery and reuse the delegate:
private static readonly Func<AppDbContext, int, ProductListItem> GetProduct =
EF.CompileQuery((AppDbContext db, int id) =>
db.Products.Where(p => p.Id == id)
.Select(p => new ProductListItem(p.Id, p.Name, p.Price))
.First());
public ProductListItem Lookup(AppDbContext db, int id) => GetProduct(db, id);The delegate is static (compiled once) and takes the DbContext plus each parameter as arguments. Use it for endpoints or loops that execute one query shape at very high frequency; it does nothing for one-off queries.
Verify: the hot loop's mean time drops with identical results.
The same SELECT repeated once per row (a navigation accessed inside a loop) is an N+1. Load the related data in one round-trip — project the aggregates with Select, or eager-load with Include:
var summaries = await db.Orders
.Select(o => new OrderSummary(o.Id, o.Items.Count, o.Items.Sum(i => i.Price)))
.ToListAsync();Prefer projection or Include over lazy loading: lazy loading is a leading cause of N+1 and forces synchronous I/O. In server apps, don't enable Microsoft.EntityFrameworkCore.Proxies or mark navigations virtual for lazy loading.
Verify: a fixed, small query count regardless of row count.
Includeing two or more collection navigations in one query multiplies rows (a Cartesian explosion) and duplicates parent data. Use AsSplitQuery() so each collection loads in its own statement; add OrderBy on a unique key so rows stitch together:
db.Blogs.Include(b => b.Posts).Include(b => b.Contributors).AsSplitQuery();Verify: rows per statement drop sharply and total duration improves.
Constrain large result sets with Where, and page with keyset (seek) pagination rather than Skip/Take, which still scans and discards the skipped rows on deep pages:
db.Orders.Where(o => o.Id > lastSeenId).OrderBy(o => o.Id).Take(pageSize);Order by a unique, stable, indexed key (add tie-breakers if the sort column isn't unique). Keyset pages by the last key seen rather than a page number, so it changes the method's inputs; when a fixed signature rules out an in-place switch, still flag the deep-offset scan and recommend keyset.
Verify: page latency stays roughly constant from early to deep pages.
Moving a filter into SQL or making a predicate sargable stops the client-side waste, but a WHERE or ORDER BY on a column with no index still scans the whole table inside the database — and a frequently-run query then re-scans it on every call. So audit index coverage separately from the query rewrite: for each query, check whether its filter and sort columns are backed by an index. Entity keys and foreign keys are indexed by convention, but other columns — status flags, state/enum fields, timestamps, names — usually are not unless the model configures it. When a hot query filters or sorts on such an unindexed column, recommend adding an index and say so explicitly, even when the rewritten query already returns the right rows: the index is a separate fix the code change alone doesn't deliver. (If the predicate isn't sargable, fix that first — a new index can't help a scan caused by a function on the column.)
If EF Core owns the schema, add the index in the model and migrate:
modelBuilder.Entity<Order>()
.HasIndex(o => new { o.CustomerId, o.CreatedAt }); // equality column first, then range/sortThen create the migration with dotnet ef migrations add .... Do not apply it with dotnet ef database update (or any equivalent that writes to the database) without explicit user approval — applying a migration mutates the database, so add the migration, show it to the user, and let them run the update once they've reviewed it. If EF Core does not own the schema, recommend the same index to whoever manages the database. Don't over-index — every index slows writes.
Verify: the plan uses a seek/index instead of a scan.
Replace a load-mutate-SaveChanges loop with ExecuteUpdateAsync/ExecuteDeleteAsync (EF Core 7+) — one statement, no entities materialized:
await db.Products.Where(p => p.LastSoldDate < cutoff)
.ExecuteUpdateAsync(s => s.SetProperty(p => p.IsActive, false));These bypass the change tracker and EF-side cascade behavior — apply related changes explicitly.
Verify: a single UPDATE/DELETE with a WHERE and no preceding SELECT.
| Pitfall | Fix |
|---|---|
Wrapping an indexed column in .Year/.Date/ToLower/arithmetic | Rewrite to a sargable range/comparison on the bare column |
| Adding an index to fix a scan on a non-sargable predicate | Fix the predicate first; the index can't help until the column is bare |
| Rewriting a filter into SQL but leaving a hot query on an unindexed column | The server-side scan is still a scan — recommend an index on the filter/sort column too |
| Compiling a query that runs only occasionally | Compile only genuinely hot, high-frequency query shapes |
Lazy loading (proxies / virtual navigations) causing N+1 and forced sync I/O | Eager-load (Include) or project; keep queries async |
ToList()/AsEnumerable() before Where/Select | Keep the query IQueryable so filtering/projection run in SQL |
© dotnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in plugins/dotnet-data/skills/optimizing-ef-core-queries of dotnet/skills.
Open the folder on GitHubat commit a660de8
We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in dotnet/skills, which our catalogue first saw on October 7, 2026.
Optimizing Ef Core Queries 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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Optimizing Ef Core Queries this skilldotnet/skills | 5.6k | 1 repos | ~2.7k | Automated safety check: Pass | MIT | |
| DB Migrationskurealnum/dotfiles | 290 | — | ~820 | Automated safety check: Pass | None | |
| Migrationkortix-ai/suna | 20k | — | ~1.2k | Automated safety check: Pass | Custom licence | |
| Database FundamentalsDanielPodolsky/ownyourcode | 290 | 1 repos | ~1.6k | Automated safety check: Pass | MIT | |
| Drizzle Orm D1secondsky/claude-skills | 227 | — | ~2.4k | Automated safety check: Pass | MIT | |
| SQL ToolkitLeoYeAI/openclaw-master-skills | 2.2k | — | ~3k | Automated safety check: Pass | MIT |
kurealnum/dotfiles
A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…
kortix-ai/suna
How to change the database schema in this repo. An agent skill from kortix-ai/suna.
DanielPodolsky/ownyourcode
Reviews schema design, SQL queries, ORM patterns. An agent skill from DanielPodolsky/ownyourcode.
secondsky/claude-skills
| Type-safe ORM for Cloudflare D1 databases using Drizzle. An agent skill from secondsky/claude-skills.
LeoYeAI/openclaw-master-skills
Query, design, migrate, and optimize SQL databases. An agent skill from LeoYeAI/openclaw-master-skills.
TheSoftwareHouse/copilot-collections
SQL writing and database engineering patterns, standards, and procedures.
dotnet/skills
Resolves .NET runtime frames in Apple .ips crash logs to function names, source files and line numbers using dSYM symbols, atos and the Microsoft symbol server.
dotnet/skills
Resolves native crash frames from .NET Android tombstones to function names, source files and line numbers using BuildIds, Microsoft's symbol server and llvm-symbolizer.
dotnet/skills
Scans C# and .NET code for about 50 performance anti-patterns and reports prioritized findings with concrete fixes, at a scan depth you choose.
dotnet/skills
Statically pairs source files with test files to list code that no test references, using Roslyn for C# or tree-sitter for many languages, with no build.
dotnet/skills
Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.
dotnet/skills
Makes .NET projects compatible with Native AOT and trimming by resolving IL trim and AOT analyzer warnings through annotations rather than suppressions.
Works with
Categories
Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Optimizing Ef Core Queries is an agent skill from dotnet/skills, published by the product's own GitHub organization. Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster.
Optimizing Ef Core Queries fits situations like: dbContext query; data-access path is slow; should be made faster — whether; not EF Core owns the database schema.
Run `npx skills add dotnet/skills --skill optimizing-ef-core-queries -a claude-code`. Or copy the skill folder (plugins/dotnet-data/skills/optimizing-ef-core-queries in dotnet/skills) into .claude/skills/optimizing-ef-core-queries in your project. Claude Code loads it when a task matches its description.
Run `npx skills add dotnet/skills --skill optimizing-ef-core-queries -a codex`. Or copy the skill folder (plugins/dotnet-data/skills/optimizing-ef-core-queries in dotnet/skills) into .agents/skills/optimizing-ef-core-queries in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dotnet/skills --skill optimizing-ef-core-queries -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimizing-ef-core-queries, .gemini/skills/optimizing-ef-core-queries, .github/skills/optimizing-ef-core-queries and .opencode/skills/optimizing-ef-core-queries in your project.
Going by SKILL.md and its folder, Optimizing Ef Core Queries needs the command-line tools its instructions call (dotnet).
SKILL.md names 1 domain. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.
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.
Optimizing Ef Core Queries is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Optimizing Ef Core Queries: DB Migrations (kurealnum/dotfiles, 290 stars), Migration (kortix-ai/suna, 20k stars), Database Fundamentals (DanielPodolsky/ownyourcode, 290 stars) and Drizzle Orm D1 (secondsky/claude-skills, 227 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
dotnet (a GitHub organization, an official publisher) maintains it in dotnet/skills, which has 5,576 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 8, 2026.
Source: 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.