- Home
- Skills
- Code Quality & Review
- .NET Async + EF Core Review (sync-over-async, N+1)
.NET Async + EF Core Review (sync-over-async, N+1)
AI agents regress to web/JS habits in C#: they block on tasks, fire `async void`, drop cancellation, and generate N+1 EF Core queries.
Free
Works with the AI Agents you already use
.NET Async + EF Core Review (sync-over-async, N+1)
Example session with this skill installed
Review Api/OrdersController.cs for async and EF Core problems before I merge. Don't change anything until you've shown me the findings.
- Read your context and instructions
- Compiled the net async
Summary
Ran the read-only scanner on Api/, then reviewed the file against the async and EF Core rules. Scanner found 2 issues. Manual review found 2 more that the heuristic doesn't catch.
Scanner output (verbatim)
Api/OrdersController.cs:7: ASYNC001 sync-over-async: .Result on an awaitable
var order = _db.Orders.FirstOrDefaultAsync(o => o.Id == id).Result;
Api/OrdersController.cs:10: ASYNC004 async void outside an event handler
public async void Refresh() { await _db.SaveChangesAsync(); }
2 finding(s).
Findings
| Line | Rule | Problem | Fix |
|---|---|---|---|
| 7 | ASYNC001 | .Result blocks a thread-pool thread and can deadlock | make Get async Task<IActionResult>, await the query |
| 10 | ASYNC004 | async void swallows exceptions and can't be awaited | return Task |
| 14-15 | N+1 (manual) | one query per order for Lines | Include(o => o.Lines) or a projection |
| 5, 12 | Cancellation (manual) | no CancellationToken passed to EF | add CancellationToken ct and pass it through |
Proposed change (line 7)
// before
public IActionResult Get(int id)
{
var order = _db.Orders.FirstOrDefaultAsync(o => o.Id == id).Result;
return Ok(order);
}
// after
public async Task<IActionResult> Get(int id, CancellationToken ct)
{
var order = await _db.Orders.AsNoTracking()
.FirstOrDefaultAsync(o => o.Id == id, ct);
return order is null ? NotFound() : Ok(order);
}
Next steps
- Approve and I'll apply all four fixes.
- I'll re-run the scanner (expect 0 findings), then
dotnet buildanddotnet test. - No performance claim until you measure it.
Connects securely to your tools. The creator never sees your data.
About this skill
AI agents regress to web/JS habits in C#: they block on tasks, fire async void, drop cancellation, and generate N+1 EF Core queries. This skill gives your agent the standing rules a senior .NET reviewer applies, plus a deterministic, stdlib-only Python scanner that flags 7 common smells (ASYNC001-004, EF001-003) before the agent changes anything.
What it does
- Scan, apply rules, verify (re-scan,
dotnet build,dotnet test) - Slow-query workflow: cause, before/after LINQ, SQL impact, index suggestion
- Output: file:line, rule, before/after, how verified. No unmeasured speedup claims.
What's inside
SKILL.mdwith when-to-apply rules and the review workflowscripts/scan_dotnet_smells.py, read-only, stdlib only, no networkreference/notes: async correctness, safe EF Core queries, optimizing a slow EF query
Limits
The scanner is heuristic. It catches common patterns, not every case (for example, an N+1 hidden inside a foreach with await is left to the agent's rule-based review). It writes nothing and makes no network calls.
Targets .NET 8+ / C# 12+, EF Core 8+. MIT licensed. Source: github.com/recsventures-ops/dotnet-ai-coding-rules
Line-based scanner heuristics may produce false positives on non-Task types. Multi-line patterns might be missed. Human validation required.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 10 days ago
- Free with an Agensi account