MVFC.Outbox.EntityFrameworkCore 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MVFC.Outbox.EntityFrameworkCore --version 1.1.0
                    
NuGet\Install-Package MVFC.Outbox.EntityFrameworkCore -Version 1.1.0
                    
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="MVFC.Outbox.EntityFrameworkCore" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MVFC.Outbox.EntityFrameworkCore" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MVFC.Outbox.EntityFrameworkCore" />
                    
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 MVFC.Outbox.EntityFrameworkCore --version 1.1.0
                    
#r "nuget: MVFC.Outbox.EntityFrameworkCore, 1.1.0"
                    
#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 MVFC.Outbox.EntityFrameworkCore@1.1.0
                    
#: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=MVFC.Outbox.EntityFrameworkCore&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MVFC.Outbox.EntityFrameworkCore&version=1.1.0
                    
Install as a Cake Tool

MVFC.Outbox.EntityFrameworkCore

🇧🇷 Leia em Português

CI codecov License Platform NuGet Version NuGet Downloads

Main guide · Playground

Shared EF Core model and optimistic concurrency adapter for Outbox storage.

Supports .NET 10 and .NET 11. Both framework targets share EF Core 10 to align with the MongoDB EF Core provider line.

dotnet add package MVFC.Outbox.EntityFrameworkCore

Configuration and usage

Snippets use application services and variables: services, configuration, connection, ct, order and topicId. Register your DbContext once, map AddOutbox() in OnModelCreating, and resolve IOutboxPublisher and your DbContext in the same DI scope.

using Microsoft.EntityFrameworkCore;
using MVFC.Outbox.EntityFrameworkCore;
using MVFC.Outbox.Publishing;

public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
    : DbContext(options)
{
    public DbSet<Order> Orders => Set<Order>();

    protected override void OnModelCreating(ModelBuilder model)
    {
        model.Entity<Order>().HasKey(order => order.Id);
        model.AddOutbox().ToTable("outbox");
    }
}

public sealed record Order(Guid Id, decimal Total);

public sealed class OrderService(ApplicationDbContext database, IOutboxPublisher publisher)
{
    public async Task CreateAsync(Order order, Guid topicId, CancellationToken ct)
    {
        await using var transaction = await database.Database.BeginTransactionAsync(ct);
        database.Orders.Add(order);
        await publisher.For(order).To(topicId).EnqueueAsync(ct);
        await database.SaveChangesAsync(ct);
        await transaction.CommitAsync(ct);
    }
}

Supported EF Core providers

This package is the shared storage layer; pick one concrete provider to register IOutboxStore and IOutboxSchemaInitializer:

Provider package Context configuration Outbox builder Model mapping
MVFC.Outbox.PostgreSql UseNpgsql(connection) UsePostgreSql<TContext>(connection) model.AddOutbox().ToTable("outbox")
MVFC.Outbox.MySql UseMySQL(connection) UseMySql<TContext>(connection) model.AddOutbox().ToTable("outbox")
MVFC.Outbox.MongoDB.EntityFrameworkCore UseMongoDB(connection, db) UseMongoDBEntityFramework<TContext>(...) model.AddOutbox().ToCollection("outbox")

Transaction boundaries and concurrency

  • Atomic business writes: generic provider overloads (Use*<TContext>) stage OutboxMessage entities directly into your registered DbContext. EnqueueAsync returns OutboxWriteState.Staged; only SaveChangesAsync and committing the transaction persist the work.
  • Non-generic overloads: registering without <TContext> uses a separate Outbox-only DbContext and cannot make writes in a separate business context atomic.
  • Relay isolation: worker relay operations (ClaimAsync, CompleteAsync, FailAsync) run in separate DI scopes and use Version as an optimistic concurrency token so competing workers cannot claim or complete the same lease simultaneously. State updates remain sequential per context.
  • Existing databases: IOutboxSchemaInitializer creates missing Outbox structures/indexes without altering unrelated tables or adding new columns (DestinationKind, ProjectId, AttributesJson) to existing tables. Use EF Core migrations for existing databases (EnsureCreated is only for local demos).

Requirements

  • A consumer application targeting .NET 10 or .NET 11.
  • An EF Core DbContext with the Outbox model mapping and a compatible database provider. Commit business changes and Outbox records through the same context and transaction.
  • For development, the playground or integration tests: the .NET 11 SDK selected by global.json, .NET 10 targeting support to build the packages, and Docker running. See the playground guide.

Contributing

See CONTRIBUTING.md to prepare the environment, run the Cake build and follow the testing and coverage conventions. Dependency versions are centralized in Directory.Packages.props.

License

Distributed under the Apache License 2.0. See LICENSE for the complete terms, including permissions, redistribution conditions, and warranty and liability limitations.

Product 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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on MVFC.Outbox.EntityFrameworkCore:

Package Downloads
MVFC.Outbox.MySql

MySQL Outbox provider using Oracle's MySQL EF Core integration.

MVFC.Outbox.PostgreSql

PostgreSQL Outbox provider using EF Core and Npgsql.

MVFC.Outbox.MongoDB.EntityFrameworkCore

Transactional Outbox staging through EF Core, with native MongoDB worker operations and schema provisioning.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 0 12/4/2026
5.0.0 65 12/3/2026
4.1.0 83 12/2/2026
4.0.0 109 12/1/2026
3.0.0 112 12/1/2026
2.0.1 119 11/30/2026
2.0.0 119 11/30/2026
1.1.1 121 11/30/2026
1.1.0 127 11/30/2026
1.0.1 126 11/30/2026
1.0.0 120 11/30/2026