I have the following structure:
public class A{}
public Class B:A
{
public virtual C { get; set;}
}
public Class C{}
public Class Context:DbContext
{
public DbSet<A> As { get; set; }
public DbSet<C> Cs { get; set; }
}
When I want to load any object b
, the property C
of this object is null. In the database the column C has an id in the table for A
. Other int
or string
properties can be loaded without a problem.
using(var ctx = new Context())
{
B b = ctx.As.FirstOrDefault() as B;
}
Can I solve this problem using lazy loading? Using Eagerly Loading I have a problem to include the property B
, because I have a list List<A> someAs
where some of the items are from type B
.
I tried to keep this example as simple as possible. Just tell me to provide more information.