MVFC.Outbox.MySql
3.0.0
See the version list below for details.
dotnet add package MVFC.Outbox.MySql --version 3.0.0
NuGet\Install-Package MVFC.Outbox.MySql -Version 3.0.0
<PackageReference Include="MVFC.Outbox.MySql" Version="3.0.0" />
<PackageVersion Include="MVFC.Outbox.MySql" Version="3.0.0" />
<PackageReference Include="MVFC.Outbox.MySql" />
paket add MVFC.Outbox.MySql --version 3.0.0
#r "nuget: MVFC.Outbox.MySql, 3.0.0"
#:package MVFC.Outbox.MySql@3.0.0
#addin nuget:?package=MVFC.Outbox.MySql&version=3.0.0
#tool nuget:?package=MVFC.Outbox.MySql&version=3.0.0
MVFC.Outbox.MySql
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
The examples use the application's services and variables: services, configuration, connection, ct, order and topicId. Register your DbContext with UseMySQL and map model.AddOutbox() in OnModelCreating.
Resolve IOutboxPublisher and ApplicationDbContext in the same dependency injection (DI) scope.
using MVFC.Outbox.EntityFrameworkCore;
using MVFC.Outbox.EntityFrameworkCore.Extensions;
using MVFC.Outbox.Extensions;
using MVFC.Outbox.MySql;
using MVFC.Outbox.MySql.Extensions;
using MVFC.Outbox.Publishing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
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);
Using your application's context:
UseMySql<ApplicationDbContext>(connection)uses your application'sDbContextand transaction.EnqueueAsyncreturnsStaged; callSaveChangesAsyncand commit to save the messages.UseMySql(connection), without a context type, uses a separate Outbox-only context.Retention: the worker removes processed records in limited batches (
CleanupInterval,CleanupBatchSize). MySQL does not use native TTL for this cleanup.
Schema initialization and existing databases
Create the database before initializing the Outbox schema. When AddOutbox(...UseMySql...) is registered, resolve IOutboxSchemaInitializer directly. To initialize the schema in a separate deployment step, without configuring topics or starting a worker, use AddMySqlOutboxSchema:
using MVFC.Outbox.MySql;
using MVFC.Outbox.MySql.Extensions;
using MVFC.Outbox.Persistence;
services.AddMySqlOutboxSchema(connection);
await using var scope = provider.CreateAsyncScope();
await scope.ServiceProvider.GetRequiredService<IOutboxSchemaInitializer>().InitializeAsync(ct);
InitializeAsynccan run repeatedly (it is idempotent). It creates theoutboxtable if needed and adds missing indexes (ix_outbox_dispatch,ix_outbox_aggregate,ix_outbox_lease,ix_outbox_expiration) without changing other tables.Run it once per deployment step with credentials that allow creating tables and indexes (DDL).
Existing databases:
InitializeAsyncdoes not add columns to an existing table. Before deploying versions withDestinationKind(Transport = 0,Handler = 1),ProjectIdandAttributesJson, 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
An 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 and integration tests, use the .NET 11 SDK specified in global.json.
To build the packages, also install .NET 10 targeting support. Keep Docker running. See the playground guide.
Contributing
See CONTRIBUTING.md to set up the environment, run the Cake build and follow the test and coverage conventions. Dependency versions are defined in Directory.Packages.props.
License
Distributed under the Apache License 2.0. See LICENSE for all terms: permissions, redistribution conditions, and limits on warranty and liability.
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.15)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.15)
- Microsoft.Extensions.Hosting (>= 10.0.15)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.15)
- MVFC.Outbox.EntityFrameworkCore (>= 3.0.0)
- MySql.EntityFrameworkCore (>= 10.0.12)
-
net11.0
- Microsoft.EntityFrameworkCore (>= 10.0.15)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.15)
- Microsoft.Extensions.Hosting (>= 11.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 11.0.0)
- MVFC.Outbox.EntityFrameworkCore (>= 3.0.0)
- MySql.EntityFrameworkCore (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.