Member-only story
5 EF Core Features Every .NET Developer Should Know to Solve Common Problems

Entity Framework Core (EF Core) is a game-changer for .NET developers who want an efficient and reliable way to interact with databases. By transforming complex SQL queries into simple C# code, EF Core takes a lot of the hassle out of working with data. But here’s the thing — many developers aren’t taking full advantage of the powerful features EF Core has to offer. Today, I’m going to share 5 EF Core features that can solve real-world developer problems and significantly improve your productivity.
These are features I wish I’d known about when I started, and I bet they’ll save you from a lot of headaches too.
1. Global Query Filters: Avoid Repetitive Filtering Logic
Problem: Are you tired of adding the same filter condition for “soft deleted” entities in every single query?
Solution: Use Global Query Filters in EF Core to automatically apply a condition across all queries for an entity. This feature is especially useful for implementing soft deletes, multi-tenancy, or any scenario where you need to consistently filter
public class AppDbContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>()
.HasQueryFilter(p => !p.IsDeleted); // Automatically filter out deleted items
}
}
With this approach, EF Core will always exclude deleted products from your queries. This saves you from the risk of forgetting to add the filter in every query and makes your code cleaner.
Keywords: EF Core Global Query Filters, EF Core soft delete, database filtering
2. Shadow Properties: Track Audit Data Without Cluttering Your Models
Problem: Need to keep track of extra information like when an item was last modified, but don’t want to clutter your entity classes?
Solution: Shadow Properties allow you to store metadata without including it directly in your C# classes. They are perfect for audit data like LastModified
or CreatedBy
, which you may need in the database but don’t want to be part of your main domain model.