Franz.Common.EntityFramework 1.4.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Franz.Common.EntityFramework --version 1.4.4
                    
NuGet\Install-Package Franz.Common.EntityFramework -Version 1.4.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Franz.Common.EntityFramework" Version="1.4.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Franz.Common.EntityFramework" Version="1.4.4" />
                    
Directory.Packages.props
<PackageReference Include="Franz.Common.EntityFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Franz.Common.EntityFramework --version 1.4.4
                    
#r "nuget: Franz.Common.EntityFramework, 1.4.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Franz.Common.EntityFramework@1.4.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Franz.Common.EntityFramework&version=1.4.4
                    
Install as a Cake Addin
#tool nuget:?package=Franz.Common.EntityFramework&version=1.4.4
                    
Install as a Cake Tool

Franz.Common.EntityFramework

A comprehensive library within the Franz Framework, designed to extend and simplify the integration of Entity Framework Core in .NET applications. It provides clean abstractions, auditing, soft deletes, repositories, and seamless integration with Franz Business and Mediator packages.


Features

  • Database Configurations*

    • Flexible options for Cosmos DB (CosmosDBConfig) and MongoDB (MongoDBConfig).
    • Centralized management of connection settings (DatabaseOptions).
  • Repositories (Separation of Entity and Aggregate Repositories)

    • EntityRepository<TEntity>: CRUD operations for standalone entities.
    • AggregateRepository<TAggregateRoot>: For event-sourced aggregates.
    • ReadRepository<T>: Optimized read-only data access.
  • DbContextBase (πŸ†• canonical context)

    • Built-in auditing (CreatedBy, CreatedOn, LastModifiedBy, LastModifiedOn).
    • Soft deletes (IsDeleted, DeletedBy, DeletedOn) with global query filters.
    • Domain event dispatching via Franz Mediator.
    • Removes the need for SaveEntitiesAsync – now everything happens in SaveChangesAsync.
  • Conversions

    • EnumerationConverter: Easily map domain enumerations to EF Core-friendly values.
  • Extensions

    • ModelBuilderExtensions: Simplify entity configuration.
    • ServiceCollectionExtensions: Wire up repositories and context with DI.

Version Information

  • Current Version: 1.4.3
  • Part of the private Franz Framework ecosystem.

πŸ†• DbContextBase 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);
    }
}

Key behaviors

  • Automatically sets CreatedBy / CreatedOn when entities are added.
  • Automatically sets LastModifiedBy / LastModifiedOn when entities are updated.
  • Marks IsDeleted / DeletedOn / DeletedBy instead of physical deletes.
  • Dispatches domain events after each save.

Repositories

1️⃣ Entity Repository (CRUD Operations)

public class OrderRepository : EntityRepository<AppDbContext, Order>
{
    public OrderRepository(AppDbContext dbContext) : base(dbContext) { }
}

βœ… Best for:

  • Entities that don’t require aggregate consistency.
  • Simple CRUD operations.

2️⃣ Aggregate Repository (Event-Sourced Aggregates)

public class ProductRepository : AggregateRepository<AppDbContext, Product, ProductEvent>
{
    public ProductRepository(AppDbContext dbContext, IEventStore eventStore)
        : base(dbContext, eventStore) { }
}

βœ… Best for:

  • Aggregates requiring event sourcing.
  • Complex domain rules.
  • Systems that replay history for consistency.

3️⃣ Choosing the Right Repository

Feature EntityRepository AggregateRepository
Use Case Standalone entities Event-sourced aggregates
CRUD Support βœ… Yes ❌ No (event-only)
Supports Event Sourcing ❌ No βœ… Yes
Direct Entity Access βœ… Yes ❌ No (root only)

Auditing & Soft Deletes

All entities deriving from Franz’s Entity<TId> automatically get:

  • CreatedOn, CreatedBy
  • LastModifiedOn, LastModifiedBy
  • IsDeleted, DeletedOn, DeletedBy

Example Entity

public class Order : Entity<Guid>
{
    public string CustomerName { get; private set; } = string.Empty;
    public decimal TotalAmount { get; private set; }

    // Domain behavior...
}

EF Core automatically filters out IsDeleted entities via a global query filter.


Installation

From Private Azure Feed

dotnet nuget add source "https://your-private-feed-url" \
  --name "AzurePrivateFeed" \
  --username "YourAzureUsername" \
  --password "YourAzurePassword" \
  --store-password-in-clear-text

Install the package:

dotnet add package Franz.Common.EntityFramework

Integration with Franz Framework

  • Franz.Common.Business β†’ DDD & CQRS building blocks.
  • Franz.Common.Mediator β†’ Pipeline behaviors & domain event dispatching.
  • Franz.Common.Errors β†’ Standardized error handling.

Contributing

This package is part of a private framework. Contributions are limited to the internal team.

  1. Clone the repository: GitHub - Franz.Common
  2. Create a feature branch.
  3. Submit a pull request.

License

Licensed under the MIT License.


Changelog

1.4.2

  • πŸ—‘οΈ Removed DbContextMultiDatabase (use DbContextBase instead).
  • πŸ—‘οΈ Removed SaveEntitiesAsync (merged into SaveChangesAsync).
  • βœ… Unified auditing, soft deletes, and domain events under DbContextBase.

1.4.1

  • Patch bump (package cleanup & docs).

1.4.0

  • Migrated to C# 12 typing rules.
  • Introduced auditing and soft delete handling in DbContextBase.
  • Aligned EnumerationConverter with stricter typing constraints.

1.2.65

  • Split repositories into EntityRepository and AggregateRepository.
  • Upgraded to .NET 9.

1.3

  • Upgraded to .NET 9.0.8.
  • Added new features and improvements.
  • Separated business from mediator concepts.
  • Compatible with Franz mediator and MediatR.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

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.PostGres

Shared utility library for the Franz Framework.

Franz.Common.SSO

Shared utility library for the Franz Framework.

Franz.Common.EntityFramework.SQLServer

Shared utility library for the Franz Framework.

Franz.Common.EntityFramework.Oracle

Shared utility library for the Franz Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.3 29 9/21/2025
1.5.2 30 9/21/2025
1.5.0 32 9/21/2025
1.4.4 75 9/20/2025
1.3.14 240 9/18/2025
1.3.13 235 9/18/2025
1.3.5 249 9/17/2025
1.3.4 263 9/16/2025
1.3.3 262 9/16/2025
1.3.2 263 9/15/2025
1.3.1 85 9/12/2025
1.3.0 290 8/25/2025
1.2.65 220 3/3/2025
1.2.64 156 1/29/2025
1.2.63 171 1/27/2025
1.2.62 157 1/8/2025