Tolitech.Infrastructure.Messaging.EntityFrameworkCore 1.0.0-preview.4

This is a prerelease version of Tolitech.Infrastructure.Messaging.EntityFrameworkCore.
dotnet add package Tolitech.Infrastructure.Messaging.EntityFrameworkCore --version 1.0.0-preview.4
                    
NuGet\Install-Package Tolitech.Infrastructure.Messaging.EntityFrameworkCore -Version 1.0.0-preview.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="Tolitech.Infrastructure.Messaging.EntityFrameworkCore" Version="1.0.0-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Infrastructure.Messaging.EntityFrameworkCore" Version="1.0.0-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Infrastructure.Messaging.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 Tolitech.Infrastructure.Messaging.EntityFrameworkCore --version 1.0.0-preview.4
                    
#r "nuget: Tolitech.Infrastructure.Messaging.EntityFrameworkCore, 1.0.0-preview.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 Tolitech.Infrastructure.Messaging.EntityFrameworkCore@1.0.0-preview.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=Tolitech.Infrastructure.Messaging.EntityFrameworkCore&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Infrastructure.Messaging.EntityFrameworkCore&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Tool

Tolitech.Infrastructure.Messaging.EntityFrameworkCore

A .NET library that implements the Outbox Pattern for reliable integration event publishing using Entity Framework Core. It provides an OutboxMessage entity and configuration utilities to persist and manage integration events, ensuring consistency between your database and message broker.

Features

  • Outbox Pattern implementation for integration events
  • Entity and configuration for storing events in the database
  • Seamless integration with Entity Framework Core
  • Support for delayed and scheduled event processing
  • Retry and error tracking for event delivery

Installation

Add the NuGet package to your project:

dotnet add package Tolitech.Infrastructure.Messaging.EntityFrameworkCore

Getting Started

1. Add the OutboxMessage Entity to Your DbContext

In your DbContext, add a DbSet<OutboxMessage>:

using Tolitech.Infrastructure.Messaging.EntityFrameworkCore.Entities;

public class MyDbContext : DbContext
{
    public DbSet<OutboxMessage> OutboxMessages { get; set; }
    // ... other DbSets
}

2. Configure the OutboxMessage Entity

In your OnModelCreating method, apply the configuration:

using Tolitech.Infrastructure.Messaging.EntityFrameworkCore.Configurations;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.ApplyConfiguration(new OutboxMessageConfiguration("OutboxMessages"));
    base.OnModelCreating(modelBuilder);
}

3. Register and Save Integration Events

Use the Outbox class to register integration events and persist them as OutboxMessage entities:

using Tolitech.Infrastructure.Messaging;
using Tolitech.Infrastructure.Messaging.EntityFrameworkCore.Entities;

// Register events
var outbox = new Outbox();
outbox.RegisterIntegrationEvent(new MyIntegrationEvent());

// Save to database
foreach (var envelope in outbox.GetIntegrationEventEnvelopes())
{
    var outboxMessage = OutboxMessage.From(envelope);
    dbContext.OutboxMessages.Add(outboxMessage);
}
await dbContext.SaveChangesAsync();

4. Processing Outbox Messages

Implement a background service or scheduled job to read, publish, and update the status of OutboxMessage records:

var pendingMessages = await dbContext.OutboxMessages
    .Where(m => !m.IsProcessed && !m.IsProcessing)
    .ToListAsync();

foreach (var message in pendingMessages)
{
    message.MarkAsProcessing();
    // Publish event to message broker
    // ...
    message.MarkAsSucceeded(); // or message.MarkAsFailed(error)
}
await dbContext.SaveChangesAsync();

Advanced

  • Supports delayed and scheduled event processing via ProcessingDelayTicks and EnqueueDateUtc.
  • Retry logic and error tracking are built-in.
  • Use indexes for efficient querying of pending messages.

Tolitech.Infrastructure.Messaging.EntityFrameworkCore enables reliable, consistent, and scalable event-driven architectures with .NET and EF Core.

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 (1)

Showing the top 1 NuGet packages that depend on Tolitech.Infrastructure.Messaging.EntityFrameworkCore:

Package Downloads
Tolitech.Infrastructure.Persistence.EntityFrameworkCore

The Tolitech.Infrastructure.Persistence.EntityFrameworkCore repository provides a foundational implementation for the Repository pattern, Unit of Work, and Specification Query Builder using Entity Framework Core. Simplify database interaction, promote code organization, and maintenance using these widely recognized patterns.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.4 434 20 days ago
1.0.0-preview.3 124 a month ago
1.0.0-preview.2 178 5 months ago
1.0.0-preview.1 73 8 months ago