Open
Description
public class Third_One : Second
{
public OwnedType ThirdOwned { get; set; }
}
public class Third_Two : Second
{
public OwnedType Third_Two_Owned { get; set; }
}
[Owned]
public class OwnedType
{
public string Value { get; set; }
}
modelBuilder.Entity<Third_One>().OwnsOne(e => e.ThirdOwned, b => b.Property(e => e.Value).HasColumnName("TValue"));
modelBuilder.Entity<Third_Two>().OwnsOne(e => e.Third_Two_Owned, b => b.Property(e => e.Value).HasColumnName("TValue").HasColumnType("nvarchar(max)"));
db.Set<Second>().Select(e => new
{
((Third_One)e).ThirdOwned,
((Third_Two)e).Third_Two_Owned,
})
Here, when selecting data from server, we get values in same column. Which is not enough to identify which entity Type it is. We decided to create a conditional based on discriminator in such cases so we get Discriminator value of principal from database and only materialize correct entity for correct principal.