What is a Global Query Filter?
Updated Apr 28, 2026
Short answer
A Global Query Filter is a LINQ predicate applied at the model level that is automatically appended to all queries for an entity type.
Deep explanation
Configured in OnModelCreating using HasQueryFilter(). It is universally applied to LINQ queries, Include properties, and navigation properties. It is exceptionally useful for Soft Deletes and Multi-tenancy.
Real-world example
Implementing a multi-tenant application where every query automatically filters by TenantId == currentTenantId to prevent data leakage.
Common mistakes
- Forgetting that Global Query Filters affect unique constraints and manual database checks, potentially causing conflicts.
Follow-up questions
- How do you temporarily bypass a Global Query Filter?