IssueRaiser

Support inheritance for owned/property bag/shared-type entity types

For example, this from #9536: ```C# 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 li

Posted by ajcvickers on Aug 30, 2017, 8:52 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

support (Other)

Support inheritance for owned/property bag/shared-type entity types

ajcvickersAug 30, 2017, 8:52 PM

For example, this from #9536: ```C# 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 li

Comments (0)

No comments yet. Start the discussion.

Comment on this issue