This project is intended as a demonstration of advanced Entity Framework Core features in a .NET-based application. It's designed to help developers understand various EF Core concepts with a focus on optimizing the performance of EF Core queries.
- .NET 9.0
- SQL Server (or compatible database)
- Update the connection string in your configuration:
- The application will automatically:
- Apply pending migrations on startup in development
- Seed initial data if the database is empty
Contains the core business entities and domain logic. The project implements:
- Strong typing for entity IDs using value objects
- Domain entities like
Customer,Account, andTransaction - Soft delete functionality through
ISoftDeleteEntityinterface
Demonstrates advanced Entity Framework Core configurations and patterns:
- Custom value object conversions
- Soft delete implementation using query filters and interceptors
- Entity configurations using
IEntityTypeConfiguration<T> - Database seeding
Implements a clean API structure using minimal APIs and demonstrates various query patterns:
- Grouped API endpoints for different domains (accounts, customers, marketing)
- Pagination implementation
- Various query optimization techniques
- Split query demonstrations for complex data loading
Value objects are immutable types that represent a concept in your domain through their values rather than their identity. They:
- Encapsulate validation logic
- Prevent primitive obsession
- Make the code more type-safe and expressive
- Ensure domain invariants are maintained
Vogen is a .NET Source Generator and analyzer that turns primitives into strongly type value objects. It has the following benefits:
-
Type Safety
- Compile-time type checking
- Prevention of accidental type mixing (e.g., can't mix CustomerId with AccountId)
- Elimination of primitive obsession
-
Code Generation
- Automatic generation of value object implementations
- Built-in validation support
- Clean, boilerplate-free code
- Source generation for better performance
-
Entity Framework Core Integration
- Seamless integration with EF Core value converters
- Automatic conversion to/from primitive types in the database
- Efficient storage and querying
-
DDD Alignment
- Natural fit with Domain-Driven Design principles
- Clear expression of domain concepts
- Improved code maintainability and readability
-
Query Filters
- Global filters for soft delete functionality
- Automated application through
ISoftDeleteEntityinterface
-
Advanced Querying
- Split queries for performance optimization
- Includes with ordering
- Pagination implementation
-
Configuration
- Fluent API configurations
- Convention-based configuration
- Alternate keys and constraints
For more information about the concepts demonstrated in this project: