Table of Contents

EfCoreTracedAggregateEntityOptions Class

Definition

Configuration options for EfCoreTracedAggregateEntity<TEntity, TKey>.

public class EfCoreTracedAggregateEntityOptions : IParameterObject
Inheritance
object
EfCoreTracedAggregateEntityOptions
Implements

Examples

EfCoreTracedAggregateEntityOptions customizes the event-store table name and column names used by ModelBuilderExtensions.AddEventSourcing. Configure it inside the setup lambda to override the defaults before EF Core creates the migration schema. The example applies custom column names and prints them to verify the configured values.

using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Savvyio.Domain.EventSourcing;
using Savvyio.Extensions.EFCore.Domain.EventSourcing;
using Savvyio.Handlers;

namespace ExampleApp;

public sealed class EventSchemaConfiguration
{
    public ModelBuilder Configure(ModelBuilder modelBuilder)
    {
        return modelBuilder.AddEventSourcing<OrderTimeline, Guid>(ConfigureOptions);
    }

    private static void ConfigureOptions(EfCoreTracedAggregateEntityOptions options)
    {
        options.TableName = "OrderTimelineEvents";
        options.CompositePrimaryKeyIdColumnName = "order_id";
        options.CompositePrimaryKeyVersionColumnName = "aggregate_version";
        options.TimestampColumnName = "recorded_at";
        options.TypeColumnName = "event_type";
        options.PayloadColumnName = "event_payload";

        Console.WriteLine($"Event table: {options.TableName}, ID column: {options.CompositePrimaryKeyIdColumnName}");
    }
}

public sealed class OrderTimeline : TracedAggregateRoot<Guid>
{
    public OrderTimeline(Guid id, string orderNumber) : base()
    {
        AddEvent(new OrderPlaced(id, orderNumber));
    }

    private OrderTimeline(Guid id, IEnumerable<ITracedDomainEvent> events) : base(id, events)
    {
    }

    protected override void RegisterDelegates(IFireForgetRegistry<ITracedDomainEvent> handler)
    {
        handler.Register<OrderPlaced>(_ => { });
    }
}

public sealed record OrderPlaced(Guid OrderId, string OrderNumber) : TracedDomainEvent;

Constructors

Name Description
EfCoreTracedAggregateEntityOptions()

Initializes a new instance of the EfCoreTracedAggregateEntityOptions class.

Properties

Name Description
CompositePrimaryKeyIdColumnName

Gets or sets the identifier part of the composite PK column name of the Event Sourcing schema.

CompositePrimaryKeyIdColumnType

Gets or sets the identifier part composite PK column type of the Event Sourcing schema.

CompositePrimaryKeyVersionColumnName

Gets or sets the version part of the composite PK column name of the Event Sourcing schema.

CompositePrimaryKeyVersionColumnType

Gets or sets the version part composite PK column type of the Event Sourcing schema.

PayloadColumnName

Gets or sets the payload (serialized data) column name of the Event Sourcing schema.

PayloadColumnType

Gets or sets the payload (serialized data) column type of the Event Sourcing schema.

TableName

Gets or sets the table name of the Event Sourcing schema.

TimestampColumnName

Gets or sets the timestamp column name of the Event Sourcing schema.

TimestampColumnType

Gets or sets the timestamp column type of the Event Sourcing schema.

TypeColumnName

Gets or sets the CLR type column name of the Event Sourcing schema.

TypeColumnType

Gets or sets the CLR type column type of the Event Sourcing schema.