Ardalis CleanArchitecture - BaseEntity & Composite Keys for AggregateRoots

107 views Asked by At

What is the recommendation for extending BaseEntity as an AggregateRoot is I need to have a composite Key?

Essentially I need to be able to manage an Entity that would normally be configured in EFCore like:

builder.HasKey(z => new { z.PartA, z.PartB });

Currently the template gives us the following definition of BaseEntity, but it's unclear to me how I might need to setup the EntityTypeCuilder config, and how the Aggregates might handle this scenario under the hood.

// This can be modified to BaseEntity<TId> to support multiple key types (e.g. Guid)
public abstract class BaseEntity
{
    public int Id { get; set; }

    public List<BaseDomainEvent> Events = new List<BaseDomainEvent>();
}

Paul

0

There are 0 answers