We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
10 things you didn't know EF Core can do - Hannes Lowette - NDC Oslo 2024
Discover 10 powerful yet lesser-known Entity Framework Core features, from inheritance strategies to JSON columns and soft deletes. Level up your EF Core skills!
-
Entity Framework Core supports multiple inheritance strategies:
- Table per Hierarchy (TPH) with discriminator column
- Table per Type (TPT) with separate tables
- Table per Concrete type (TPC)
-
JSON columns can be used to store complex nested objects instead of normalizing them into separate tables
- Reduces joins and simplifies querying
-
Uses
OwnsOne()
with JSON serialization - Good for nested DTOs and value objects
-
HierarchyID support for modeling tree structures in SQL Server
- More efficient than self-referencing foreign keys
- Enables complex tree traversal queries
- Requires SQL Server.HierarchyId package
-
Many-to-many relationships can be configured without explicitly mapping join tables
- Simplified syntax with skip navigation
- Can control join table naming and structure
- Supports bi-directional navigation
-
Owned types allow modeling complex types without separate tables
- Can be mapped as JSON or normalized tables
- Supports collections
- Automatically loaded with parent entity
-
Compiled queries improve performance by caching query plans
- Reduces parsing overhead
- Good for frequently executed queries
- Supports parameterization
-
Logical/soft deletes can be implemented using shadow properties and global filters
- Records marked as deleted instead of physically removed
- Filtered out automatically from queries
- Configurable through model building
-
DbContext can be used without DbSet properties
- Model can be built at runtime
- Useful for plugin architectures
- Supports dynamic model configuration
-
Batch operations reduce database roundtrips
- Multiple operations sent in single transaction
- Configurable batch size (default 42)
- Improves performance for bulk operations