Table of Contents

Class EfCoreTracedAggregateEntityOptions

Namespace
Savvyio.Extensions.EFCore.Domain.EventSourcing
Assembly
Savvyio.Extensions.EFCore.Domain.EventSourcing.dll

Configuration options for EfCoreTracedAggregateEntity<TEntity, TKey>.

public class EfCoreTracedAggregateEntityOptions : IParameterObject
Inheritance
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

EfCoreTracedAggregateEntityOptions()

Initializes a new instance of the EfCoreTracedAggregateEntityOptions class.

public EfCoreTracedAggregateEntityOptions()

Remarks

The following table shows the initial property values for an instance of EfCoreTracedAggregateEntityOptions.

PropertyInitial Value
TableNameDomainEvents
CompositePrimaryKeyIdColumnNameid
CompositePrimaryKeyIdColumnTypeuniqueidentifier
CompositePrimaryKeyVersionColumnNameversion
CompositePrimaryKeyVersionColumnTypeint
TimestampColumnNametimestamp
TimestampColumnTypedatetime
TypeColumnNametype
TypeColumnTypevarchar(1024)
PayloadColumnNamepayload
PayloadColumnTypevarchar(max)

Properties

CompositePrimaryKeyIdColumnName

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

public string CompositePrimaryKeyIdColumnName { get; set; }

Property Value

string

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.

public string CompositePrimaryKeyIdColumnType { get; set; }

Property Value

string

The identifier part of the 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.

public string CompositePrimaryKeyVersionColumnName { get; set; }

Property Value

string

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.

public string CompositePrimaryKeyVersionColumnType { get; set; }

Property Value

string

The version part of the composite PK column type of the Event Sourcing schema.

PayloadColumnName

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

public string PayloadColumnName { get; set; }

Property Value

string

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.

public string PayloadColumnType { get; set; }

Property Value

string

The payload (serialized data) column type of the Event Sourcing schema.

TableName

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

public string TableName { get; set; }

Property Value

string

The table name of the Event Sourcing schema.

TimestampColumnName

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

public string TimestampColumnName { get; set; }

Property Value

string

The timestamp column name of the Event Sourcing schema.

TimestampColumnType

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

public string TimestampColumnType { get; set; }

Property Value

string

The timestamp column type of the Event Sourcing schema.

TypeColumnName

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

public string TypeColumnName { get; set; }

Property Value

string

The CLR type column name of the Event Sourcing schema.

TypeColumnType

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

public string TypeColumnType { get; set; }

Property Value

string

The CLR type column type of the Event Sourcing schema.