linq2db.EntityFrameworkCore
linq2db.EntityFrameworkCore copied to clipboard
Inherited Include not populated?
Let's assume I have theese entities:
public class Base
{
public Guid Id {get; set;}
[ForeignKey("Other")]
public Guid OtherId {get; set;}
public Other Other {get; set;}
}
public class Inherited : Base
{
public string SomeValue {get; set;}
}
public class Other
{
public Guid Id {get; set;}
[InverseProperty("Other")]
public virtual ICollection<Base> Values {get; set;}
}
Now, I have 1 element of type Other and 1 element of type Inherited, having a relation between themselves.
The query
_context.Others
.Include(o => o.Values)
.ToArrayAsyncLinqToDB()
mostly works but with one catch. When iterating over Other.Values they are all retrieved as "Base" from db, not as "Inherited", so I can't cast them to "Inherited". The same query done by EF Core makes them "Inherited" so I can cast them. What am I doing wrong?
I guess this falls under the "hierarchy per table" thing which isn't really supported, right?
No idea how inheritance mapping configured in EF.Core, but:
- linq2db needs discriminator field to distinguish Base from Inherited
- I don't see any inheritance-related stuff configured in EF.Core to linq2db mapping code here
Well, EF Core itself does create a "Discriminator" field in the database itself...