Franz.Common.EntityFramework
2.1.1
dotnet add package Franz.Common.EntityFramework --version 2.1.1
NuGet\Install-Package Franz.Common.EntityFramework -Version 2.1.1
<PackageReference Include="Franz.Common.EntityFramework" Version="2.1.1" />
<PackageVersion Include="Franz.Common.EntityFramework" Version="2.1.1" />
<PackageReference Include="Franz.Common.EntityFramework" />
paket add Franz.Common.EntityFramework --version 2.1.1
#r "nuget: Franz.Common.EntityFramework, 2.1.1"
#:package Franz.Common.EntityFramework@2.1.1
#addin nuget:?package=Franz.Common.EntityFramework&version=2.1.1
#tool nuget:?package=Franz.Common.EntityFramework&version=2.1.1
๐ฆ Franz.Common.EntityFramework
A core infrastructure library of the Franz Framework, designed to extend and simplify Entity Framework Core integration in .NET systems.
It provides a pragmatic persistence layer, supporting:
- Domain-Driven Design (selectively applied)
- CQRS architectures
- Soft deletes + auditing
- Event-driven persistence patterns
- DI-driven modular design
Unlike strict DDD implementations, this library follows a system-first pragmatic architecture, where domain purity is preserved only where it adds value.
๐ Version
v2.1.1
๐ง Architectural Philosophy
This library is built on a pragmatic DDD enforcement model:
DDD is applied where it improves domain correctness, not as a global constraint.
Core principles:
- Persistence is EF-native, not domain-driven
- Repositories are identity-agnostic (
IEntity) - Domain identity (
Entity<TId>) is isolated from persistence contracts - DI is explicit and convention-based
- Infrastructure is optimized for scalability over theoretical purity
๐งฑ Core Concepts
1. DbContextBase (Canonical EF Context)
The base DbContext provides:
โ Built-in Features
- Auditing (
CreatedBy,CreatedOn, etc.) - Soft deletes (
IsDeleted,DeletedOn,DeletedBy) - Global query filters
- Domain event dispatching via
IDispatcher - Current user tracking integration
๐ Example
public class AppDbContext : DbContextBase
{
public AppDbContext(
DbContextOptions<AppDbContext> options,
IDispatcher dispatcher,
ICurrentUserService currentUser)
: base(options, dispatcher, currentUser)
{
}
public DbSet<Order> Orders => Set<Order>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly);
}
}
๐ง Behavior Summary
- Automatically applies auditing on
SaveChanges - Converts deletes into soft deletes
- Filters deleted entities globally
- Dispatches domain events after persistence
2. Repository System (Pragmatic Model)
The repository system is intentionally simplified for scalability.
๐ฆ EntityRepository (CRUD)
public class EntityRepository<TDbContext, TEntity>
where TDbContext : DbContext
where TEntity : class, IEntity
โ Responsibilities:
- CRUD operations
- EF Core persistence
- Soft delete compliance
- No domain logic
- No identity assumptions
๐ Example
public class OrderRepository
: EntityRepository<AppDbContext, Order>
{
public OrderRepository(AppDbContext dbContext)
: base(dbContext) { }
}
๐ง Key Design Rule
Repositories do NOT manage identity.
Identity is handled by:
IEntity.GetId()- EF Core key resolution
- Domain layer (
Entity<TId>)
๐ฆ AggregateRepository (Event-Sourced)
Used for event-driven aggregates.
public class AggregateRepository<TDbContext, TAggregateRoot, TEvent>
โ Responsibilities:
- Event sourcing persistence
- Aggregate rehydration
- Event storage coordination
- Domain event consistency
3. Auditing System
All entities implementing Entity<TId> automatically support:
CreatedOn,CreatedByLastModifiedOn,LastModifiedByDeletedOn,DeletedByIsDeletedsoft delete flag
โ Behavior
- Automatically applied on
SaveChanges - Fully transparent to application layer
- No manual intervention required
4. Soft Delete System
Instead of physical deletion:
DELETE โ UPDATE IsDeleted = true
โ Features:
- Global EF query filter
- Automatic exclusion of deleted entities
- Audit trail preserved
5. Domain Events Integration
DbContext automatically dispatches domain events via:
IDispatcher
โ Lifecycle:
- Entity changes tracked
- SaveChanges executed
- Events collected
- Dispatcher publishes after commit
6. Entity Framework Conventions
โ Supported entity model
public abstract class Entity<TId> : IEntity
โ Characteristics:
- Strongly typed identity (
TId) - EF-compatible mapping
- Audit support (via DbContext)
- Soft delete support
โ Identity rules
- Identity is defined in the domain (
Entity<TId>) - Repositories are identity-agnostic
- EF resolves identity via
object[]keys
7. Dependency Injection Model
This framework uses explicit DI discovery.
โ Auto-registration rules
Only services implementing:
IScopedDependencyISingletonDependency
are automatically registered.
โ Benefits
- No hidden service locator
- Fully deterministic composition
- Explicit module boundaries
- Scalable modular architecture
8. Configuration Extensions
โ Register EF Infrastructure
services.AddEntityFrameworkFranz();
Includes:
- DbContextBase support
- repositories
- auditing pipeline
- DI wiring
โ ๏ธ Design Constraints
โ Do NOT
- Inject identity logic into repositories
- Use repository-level
TIdconstraints - Bypass
Entity<TId>model - Perform manual auditing
โ Always
- Let EF handle persistence
- Let domain handle identity
- Use repositories as orchestration layer only
- Use DI markers for registration
๐งญ Architecture Overview
Domain Layer
โโโ Entity<TId>
โโโ Domain Events
โโโ Aggregates
Application Layer
โโโ CQRS / Mediator
Infrastructure Layer
โโโ DbContextBase
โโโ EntityRepository
โโโ AggregateRepository
EF Core Layer
โโโ DbSet<TEntity>
โโโ ChangeTracker
โโโ Global Filters
DI Layer
โโโ IScopedDependency
โโโ IServiceCollection extensions
๐งช Version History
v2.0.3 โ Pragmatic Architecture Alignment
๐ง Major Changes
- Replaced identity-coupled repositories with
IEntity-based model - Removed
TIddependency from repository contracts - Standardized EF Core identity resolution via
object - Introduced explicit DI-based service discovery model
- Reinforced pragmatic DDD enforcement strategy
โ๏ธ Improvements
- Reduced repository complexity
- Simplified DI wiring
- Improved EF Core compatibility
- Strengthened infrastructure scalability
โ ๏ธ Design Trade-off
- Reduced compile-time identity enforcement in repositories
- Identity safety moved to domain layer (
Entity<TId>)
๐ Summary
Franz.Common.EntityFramework v2.0.3 provides:
โ EF-native persistence layer โ Pragmatic DDD enforcement โ Scalable repository abstraction โ Auditing + soft delete system โ Event-driven persistence support โ DI-driven modular architecture
๐ง Final Statement
This library prioritizes system scalability and architectural clarity over theoretical purity, applying DDD only where it improves correctness, not as a global constraint.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Franz.Common.Business (>= 2.1.1)
- Franz.Common.DependencyInjection (>= 2.1.1)
- Franz.Common.Errors (>= 2.1.1)
- Franz.Common.MultiTenancy (>= 2.1.1)
- Franz.Common.Reflection (>= 2.1.1)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.EntityFrameworkCore.Cosmos (>= 10.0.5)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.5)
- MongoDB.Driver (>= 3.7.1)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Franz.Common.EntityFramework:
| Package | Downloads |
|---|---|
|
Franz.Common.EntityFramework.MariaDB
Shared utility library for the Franz Framework. |
|
|
Franz.Common.EntityFramework.SQLServer
Shared utility library for the Franz Framework. |
|
|
Franz.Common.EntityFramework.PostGres
Shared utility library for the Franz Framework. |
|
|
Franz.Common.MongoDB
Shared utility library for the Franz Framework. |
|
|
Franz.Common.SSO
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.1 | 86 | 4/22/2026 |
| 2.0.2 | 166 | 3/30/2026 |
| 2.0.1 | 155 | 3/29/2026 |
| 1.7.8 | 165 | 3/2/2026 |
| 1.7.7 | 183 | 1/31/2026 |
| 1.7.6 | 183 | 1/22/2026 |
| 1.7.5 | 185 | 1/10/2026 |
| 1.7.4 | 175 | 12/27/2025 |
| 1.7.3 | 262 | 12/22/2025 |
| 1.7.2 | 249 | 12/21/2025 |
| 1.7.1 | 202 | 12/20/2025 |
| 1.7.0 | 353 | 12/16/2025 |
| 1.6.21 | 267 | 11/27/2025 |
| 1.6.20 | 279 | 11/24/2025 |
| 1.6.19 | 271 | 10/25/2025 |
| 1.6.15 | 304 | 10/20/2025 |
| 1.6.14 | 312 | 10/15/2025 |
| 1.6.3 | 306 | 10/9/2025 |
| 1.6.2 | 296 | 10/7/2025 |
| 1.5.9 | 315 | 9/24/2025 |