-
-
Notifications
You must be signed in to change notification settings - Fork 457
Open
Description
I'm using EventFlow with MongoDB, and I noticed that the constraint (AggregateId + AggregateSequenceNumber) is not being created.
After checking the source code, I found that other database implementations like MySQL and PostgreSQL create this constraint directly via the initialization scripts.
However, for MongoDB, there is a method called Initialize() that appears to be responsible for setting up this constraint, but it doesn't seem to be called anywhere.
Is this intentional, or is it possibly a bug?
Suggestions for a fix:
In EventFlowOptionsMongoDbEventStoreExtensions.cs:
public static IEventFlowOptions UseMongoDbEventStore(this IEventFlowOptions eventFlowOptions)
{
eventFlowOptions.UseEventPersistence<MongoDbEventPersistence>();
eventFlowOptions.ServiceCollection
.TryAddTransient<IMongoDbEventPersistenceInitializer, MongoDbEventPersistenceInitializer>();
// Add this block of code
using var serviceProvider = eventFlowOptions.ServiceCollection.BuildServiceProvider();
var initializer = serviceProvider.GetRequiredService<IMongoDbEventPersistenceInitializer>();
initializer.Initialize();
return eventFlowOptions;
}