I am modeling the following many-to-many relationship using Domain Driven Design (DDD).
I am using EF Core for persistence.
The collection on Person is configured like this:
PersonConfigurations.cs
builder.OwnsMany(o => o.PersonOrgIds, ib =>
{
ib.ToTable("PersonPersonOrgIds");
ib.WithOwner()
.HasForeignKey("PersonId");
ib.HasKey("Id");
ib.Property(id => id.Value)
.HasColumnName("PersonOrgId");
});
builder.Metadata.FindNavigation(nameof(Person.PersonOrgIds))!
.SetPropertyAccessMode(PropertyAccessMode.Field);
Then PersonOrg models the relationship like this:
PersonOrgConfigurations.cs
builder.Property(o => o.PersonId).IsRequired()
.HasConversion(
id => id.Value,
value => PersonId.Create(value));
My question is when I add a PersonOrg how can I reflect that in the collection of Person (and Org).
