Integration Testing ASP.NET Core APIs The Right Way with WebApplicationFactory

A comprehensive guide to integration testing ASP.NET Core APIs with WebApplicationFactory. Learn to replace real databases, mock services, test authenticated endpoints, and build production-ready test suites.

November 16, 2025 · 7 min
An illustration of a Swiss Army knife with an absurd number of impractical tools, representing the "generic hell" of over-engineered generic repositories.

Building Maintainable EF Core Repositories Without Generic Hell

Most EF Core projects start with a generic repository that soon turns into a mess of type parameters and leaky abstractions. In this post, learn how to design maintainable, aggregate-specific repositories that are clean, testable, and production-ready.

November 13, 2025 · Last modified: November 25, 2025 · 10 min

Optimistic vs. Pessimistic Concurrency in EF Core: A Conceptual Deep Dive

EF Core’s default optimistic concurrency model is a great starting point, but it’s not a silver bullet. When write contention heats up, its limitations can lead to performance bottlenecks and data integrity challenges. Understanding the trade-offs between optimistic and pessimistic concurrency is crucial for building robust, scalable applications. This article explores the conceptual costs and benefits of each strategy, helping you decide when to stick with the default and when to reach for explicit locking. ...

November 4, 2025 · 9 min

IAsyncEnumerable vs Task.WhenAll: Choosing Between Speed and User Experience in C#

Real benchmark results comparing IAsyncEnumerable and Task.WhenAll. Learn when to choose speed vs responsiveness, memory efficiency, and user experience in C# async operations.

October 16, 2025 · 9 min

SQL Indexing Strategies Every Developer Should Know

A practical guide to SQL indexing strategies every developer should know. Includes real-world scenarios, code examples, and performance tuning insights.

October 11, 2025 · 7 min

EF Core Interceptors for Secure, Per-Tenant Audit Logging

TL;DR In multi-tenant SaaS, generic audit logging can easily leak data between tenants. This is a security and compliance nightmare. Overriding DbContext.SaveChanges() is a common but clunky solution that tightly couples auditing logic to your data context. EF Core Interceptors provide a clean, decoupled way to hook into the save process and add per-tenant audit logs automatically. The solution involves creating a SaveChangesInterceptor, grabbing the current TenantId from a scoped service, and logging entity changes before they hit the database. This pattern is perfect for auditable, compliant SaaS applications but might be overkill for simple, single-server projects. I once got a panicked call about a critical bug. An admin from “Company A” could see user creation events from “Company B” in their audit trail. It was a classic multi-tenant data bleed, but not in the main application data—it was in the logs. This is one of those sneaky bugs that passes all unit tests but can absolutely destroy trust with your customers and fail a compliance audit. ...

October 3, 2025 · 8 min

Top 11 EF Core Mistakes That Kill Performance

A comprehensive guide to diagnosing and fixing common EF Core performance issues, with practical code examples and real-world performance improvements.

July 17, 2025 · Last modified: September 20, 2025 · 22 min

Avoiding N+1 Queries in EF Core: Include() vs SplitQuery()

A practical guide to fixing N+1 queries in EF Core using Include and AsSplitQuery, with code samples and performance tips.

July 8, 2025 · Last modified: July 10, 2025 · 11 min
×