Tolitech.Infrastructure.Messaging.EntityFrameworkCore
1.0.0-preview.4
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
<PackageReference Include="Tolitech.Infrastructure.Messaging.EntityFrameworkCore" Version="1.0.0-preview.4" />
<PackageVersion Include="Tolitech.Infrastructure.Messaging.EntityFrameworkCore" Version="1.0.0-preview.4" />
<PackageReference Include="Tolitech.Infrastructure.Messaging.EntityFrameworkCore" />
paket add Tolitech.Infrastructure.Messaging.EntityFrameworkCore --version 1.0.0-preview.4
#r "nuget: Tolitech.Infrastructure.Messaging.EntityFrameworkCore, 1.0.0-preview.4"
#:package Tolitech.Infrastructure.Messaging.EntityFrameworkCore@1.0.0-preview.4
#addin nuget:?package=Tolitech.Infrastructure.Messaging.EntityFrameworkCore&version=1.0.0-preview.4&prerelease
#tool nuget:?package=Tolitech.Infrastructure.Messaging.EntityFrameworkCore&version=1.0.0-preview.4&prerelease
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
andEnqueueDateUtc
. - 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 | Versions 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. |
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.6)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.6)
- Tolitech.Infrastructure.Messaging (>= 1.0.0-preview.4)
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 |