I’m trying to use NServiceBus in .NET 8 with EF Core 8. It’s important to get the transaction outbox working.
Specifically, this code is to setup transaction sharing. The problem is, this sample is for EF Core 7 and there is no EF Core 8 sample. In EF Core 8, UseTransaction
was removed
The sample code from Particular is here:
https://docs.particular.net/samples/entity-framework-core/
endpointConfiguration.RegisterComponents(c =>
{
c.AddScoped(b =>
{
var session = b.GetRequiredService<ISqlStorageSession>();
var context = new ReceiverDataContext(new DbContextOptionsBuilder<ReceiverDataContext>()
.UseSqlServer(session.Connection)
.Options);
// This is bad, UseTransaction was removed.
context.Database.UseTransaction(session.Transaction);
//Ensure context is flushed before the transaction is committed
session.OnSaveChanges((s, token) => context.SaveChangesAsync(token));
return context;
});
});