Tutorials Entity Framework Core Tutorial
Production Monitoring for EF Core
Production Monitoring for EF Core: 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 90 of 100
Production Monitoring for EF Core
Beginner ✓ → Intermediate ✓ → Advanced ✓ → Professional
Professional · 4 — Real projects · ~10 min · Module 9: Testing & Debugging
What is this?
Production monitoring tracks EF health — slow dependency calls in APM, SQL deadlock rates, connection pool metrics, and migration version drift across instances.
Why should you care?
ShopNest Black Friday needs alerts when SQL dependency duration spikes or __EFMigrationsHistory lags on a pod.
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).
// Application Insights automatic dependency tracking captures SQL
builder.Services.AddApplicationInsightsTelemetry();
// Custom metric on SaveChanges:
public override async Task<int> SaveChangesAsync(CancellationToken ct = default)
{
var sw = Stopwatch.StartNew();
var count = await base.SaveChangesAsync(ct);
_telemetry.TrackMetric("ShopNest.SaveChanges.DurationMs", sw.ElapsedMilliseconds);
_telemetry.TrackMetric("ShopNest.SaveChanges.AffectedRows", count);
return count;
}
What happened?
- Application Insights traces SQL dependencies per request.
- Custom metrics on SaveChanges highlight slow commits.
- Compare migration history table across environments in release checklist.
Practice next
- Enable APM SQL dependency collection on ShopNest API.
- Alert when p95 SQL dependency exceeds threshold.
- Dashboard connection count and deadlock DMVs on SQL Server.
- Add health check: db.Database.GetPendingMigrationsAsync() empty.
- Log TagWith query names into App Insights custom properties.
Remember
APM tracks EF SQL dependencies. Custom metrics on SaveChanges optional. Migration drift checks part of deploy.
ShopNest ops dashboard
Pager fires when ShopNest SQL dependency p95 > 500ms during sale — runbook checks blocking DMVs.
Outcome: Incident resolved in 12 minutes with telemetry pinpointing category query regression.
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!