Interface IOutboxDbContext
Interface that DbContext classes must implement to support the outbox pattern.
public interface IOutboxDbContext
Examples
public class MyDbContext : DbContext, IOutboxDbContext
{
public OutboxStagingCollection OutboxMessages { get; } = new();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.AddRatatoskrEfCoreModel(Database);
}
// Usage in application code:
// db.MyEntities.Add(entity);
// db.OutboxMessages.Add(new MyEvent { ... });
// await db.SaveChangesAsync(); // Both saved transactionally
}
Properties
- OutboxMessages
Collection for staging messages to be sent via the outbox. Messages added here will be persisted and sent when SaveChanges is called.