-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
For example, this from #9536:
public class Friend
{
public int Id { get; set; }
public string Name { get; set; }
public FullAddress Address { get; set; }
}
public class LessThanFriend
{
public int Id { get; set; }
public string Name { get; set; }
public CityAddress Address { get; set; }
}
public class CityAddress
{
public string Cap { get; set; }
public string City { get; set; }
}
public class FullAddress : CityAddress
{
public string Street { get; set; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Friend>().OwnsOne(e => e.Address);
modelBuilder.Entity<LessThanFriend>().OwnsOne(e => e.Address);
}This is ambiguous as to whether LessThanFriend.CityAddress should be mapped to allow inheritance such that either a CityAddress or a FullAddress could be persisted. Typically, we only map inheritance when both types are in the model. However, having both types in the model as Owned types on different entities perhaps does not have the same semantics--especially when thinking of them like complex types.
Based on triage discussion from #9536, we think we want to support both the simple mapping (just persisting given concrete type, which is what the request on #9536 is for) and the inheritance mapping, which would require, for TPH, and additional discriminator column in the table. We did not come to a final decision on which should be the default, or what the new API will look like to switch between the two.