Tutorials Entity Framework Core Tutorial
Performance Profiling EF Core Queries
Performance Profiling EF Core Queries: free step-by-step lesson with examples, common mistakes, and interview tips — part of Entity Framework Core Tutorial on Toolliyo Academy.
On this page
Entity Framework Core Tutorial · Lesson 87 of 100
Performance Profiling EF Core Queries
Beginner ✓ → Intermediate ✓ → Advanced ✓ → Professional
Professional · 4 — Real projects · ~10 min · Module 9: Testing & Debugging
What is this?
Profiling measures query duration and frequency — MiniProfiler, Application Insights, EF tags, and SQL Server Extended Events combined pinpoint EF bottlenecks.
Why should you care?
ShopNest p95 regression after release needs evidence — profiler shows which LINQ method generates slow SQL.
See it live — copy this example
Paste into a .NET project with EF Core packages, then run with LocalDB/SQL Server (dotnet ef / dotnet run).
services.AddMiniProfiler(o =>
{
o.TrackConnectionString = true;
}).AddEntityFramework();
// Controller or middleware:
app.UseMiniProfiler();
// In view or API diagnostic header:
// MiniProfiler.Current?.RenderIncludes(_accessor.HttpContext)
What happened?
- MiniProfiler wraps DbConnection to time each command.
- AddEntityFramework integrates EF events.
- Developer sees SQL timeline per HTTP request in dev UI.
Practice next
- Install MiniProfiler for local request-level SQL timeline.
- Compare profiler SQL count before/after Include fix.
- Export slow query to SSMS with actual execution plan.
- Add custom step around SaveChangesAsync in handler with MiniProfiler.CustomTiming.
- Correlate App Insights trace id with TagWith query tags.
Remember
MiniProfiler shows SQL per request. Combine with SQL execution plans. Profile realistic data volumes.
ShopNest profiler RCA
MiniProfiler on staging shows OrderDetail query 450ms — missing index on OrderId identified.
Outcome: Index migration ships same sprint as profiler evidence screenshot.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!