Say I have a Customer entity with a list of owned types of Address. I also have an Office entity also with a list of owned types of Address.
In my OnModelCreating() method I have:
modelBuilder.Entity<Customer>().OwnsMany(s => s.Addresses, a =>
{
a.Property<DateTime>("CreatedDate");
a.Property<DateTime>("UpdatedDate");
}).ToTable("CustomerAddresses");
modelBuilder.Entity<Office>().OwnsMany(s => s.Addresses, a =>
{
a.Property<DateTime>("CreatedDate");
a.Property<DateTime>("UpdatedDate");
}).ToTable("OfficeAddresses");
I get an error of:
"Cannot use table 'Addresses' for entity type 'Customer.Addresses#Address' since it is being used for entity type 'Office.Addresses#Address' and there is no relationship between their primary keys.".
However, if I just have:
modelBuilder.Entity<Customer>().OwnsMany(s => s.Addresses).ToTable("CustomerAddresses");
modelBuilder.Entity<Office>().OwnsMany(s => s.Addresses).ToTable("OfficeAddresses");
it works.
So how do I add the shadow properties to this?
The solution if found is: