MVFC.Outbox.MySql 1.1.1

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

MVFC.Outbox.MySql

🇧🇷 Leia em Português

CI codecov License Platform NuGet Version NuGet Downloads

Main guide · Playground

MySQL Outbox provider using Oracle's MySQL EF Core integration (MySql.EntityFrameworkCore).

Supports .NET 10 and .NET 11.

dotnet add package MVFC.Outbox.MySql

Configuration and usage

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

using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using MVFC.Outbox.DependencyInjection;
using MVFC.Outbox.EntityFrameworkCore;
using MVFC.Outbox.Publishing;
using MVFC.Outbox.MySql;

services.AddDbContext<ApplicationDbContext>(db => db.UseMySQL(connection));
services.AddOutbox(configuration, outbox => outbox.ProducerOnly()
    .MapAggregate<Order, Guid>(order => order.Id, "order")
    .UseMySql<ApplicationDbContext>(connection));

// Same scoped ApplicationDbContext used by the publisher:
await using var transaction = await database.Database.BeginTransactionAsync(ct);
database.Orders.Add(order);
await publisher.For(order).To(topicId).EnqueueAsync(ct);
await publisher.ForEach(otherOrders).To(topicId).EnqueueAsync(ct);
await database.SaveChangesAsync(ct);
await transaction.CommitAsync(ct);

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);
  • Generic vs non-generic overload: UseMySql<ApplicationDbContext>(connection) shares your application's DbContext and transaction (EnqueueAsync returns Staged and requires SaveChangesAsync/commit). The non-generic UseMySql(connection) uses an isolated Outbox-only context.
  • Retention: processed records use bounded worker cleanup (CleanupInterval, CleanupBatchSize) rather than native TTL.

Schema initialization and existing databases

The database must already exist. When AddOutbox(...UseMySql...) is registered, resolve IOutboxSchemaInitializer directly. For a dedicated deployment step without topics or a worker, use AddMySqlOutboxSchema:

using MVFC.Outbox.MySql;
using MVFC.Outbox.Persistence;

services.AddMySqlOutboxSchema(connection);
await using var scope = provider.CreateAsyncScope();
await scope.ServiceProvider.GetRequiredService<IOutboxSchemaInitializer>().InitializeAsync(ct);
  • InitializeAsync is idempotent, creates the outbox table if missing, and repairs missing indexes (ix_outbox_dispatch, ix_outbox_aggregate, ix_outbox_lease, ix_outbox_expiration) without modifying unrelated tables. Run it once per deployment step using a DDL-capable identity.
  • Existing databases: InitializeAsync does not add columns to an existing table. Before deploying versions with DestinationKind (Transport = 0, Handler = 1), ProjectId and AttributesJson, apply a reviewed EF migration or equivalent DDL (only when columns are missing):
ALTER TABLE outbox
    ADD COLUMN DestinationKind int NOT NULL DEFAULT 0,
    ADD COLUMN ProjectId varchar(256) NULL,
    ADD COLUMN AttributesJson longtext NULL;

Requirements

  • A consumer application targeting .NET 10 or .NET 11.
  • Access to a MySQL database with transactional tables and an EF Core context configured with the MySQL provider. Schema initialization needs permission to create the Outbox table and indexes.
  • 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

This package is not used by any NuGet packages.

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 66 12/3/2026
4.1.0 72 12/2/2026
4.0.0 85 12/1/2026
3.0.0 88 12/1/2026
2.0.1 95 11/30/2026
2.0.0 89 11/30/2026
1.1.1 92 11/30/2026
1.1.0 94 11/30/2026
1.0.1 92 11/30/2026
1.0.0 90 11/30/2026