I'm trying to store events in the Warehouses table per product id.
And all the events are inherited from WarehouseEventBase.
But now it's impossible to have TPH (Table Per Hierarchy) with owned types, like this:
internal sealed class WarehouseEntityTypeConfiguration : IEntityTypeConfiguration<Warehouse>
{
public void Configure(EntityTypeBuilder<Warehouse> builder)
{
builder.ToTable("Warehouses");
builder.HasKey(warehouse => warehouse.ProductId);
builder.Property(warehouse => warehouse.ProductId)
.HasColumnName(nameof(Product.Id))
.HasConversion(id => id.Value, value => new ProductId(value));
builder.OwnsMany(warehouse => warehouse.DomainEvents, navigationBuilder =>
{
navigationBuilder.UsePropertyAccessMode(PropertyAccessMode.Field);
});
}
}
internal sealed class WarehouseEventBaseTypeConfiguration : IEntityTypeConfiguration<WarehouseEventBase>
{
public void Configure(EntityTypeBuilder<WarehouseEventBase> builder)
{
builder.HasDiscriminator<string>(nameof(WarehouseEventBase))
.HasValue<WarehouseCreatedEvent>(nameof(WarehouseCreatedEvent))
.HasValue<ProductsShippedEvent>(nameof(ProductsShippedEvent))
.HasValue<ProductsMissedEvent>(nameof(ProductsMissedEvent))
.HasValue<ProductsReceivedEvent>(nameof(ProductsReceivedEvent));
}
}
This behavior should be implemented as soon as the feature will be added to ef core 8.
Related issue: dotnet/efcore#9630
I'm trying to store events in the Warehouses table per product id. And all the events are inherited from
WarehouseEventBase
. But now it's impossible to have TPH (Table Per Hierarchy) with owned types, like this:This behavior should be implemented as soon as the feature will be added to ef core 8. Related issue: dotnet/efcore#9630