using Flensrocker.EventSourcing.Abstractions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Flensrocker.EventSourcing.Persistence.EntityFrameworkCore;
public class EntityFrameworkCoreDomainEventStoreBuilder
{
private readonly IServiceCollection _services;
public EntityFrameworkCoreDomainEventStoreBuilder(IServiceCollection services)
{
_services = services;
}
///
/// Use this overload if you want to implement strong consistent projections on your DbContext.
/// The DbContext has to call modelBuilder.ApplyDBPROVIDEREventSourcingConfiguration(excludeFromMigrations: true) in its configuration.
///
public EntityFrameworkCoreDomainEventStoreBuilder ForDomainEvents()
where TEventBase : class
where TDbContext : DbContext
{
_services.AddScoped>();
_services.AddScoped>(sp =>
sp.GetRequiredService>()
);
return this;
}
public EntityFrameworkCoreDomainEventStoreBuilder ForDomainEvents()
where TEventBase : class
{
return ForDomainEvents();
}
}