I'm sharing one entity between other entities with selector property. Code First codes are :
public enum ContentTypes : byte
{
EntityA = 0,
EntityB = 1
}
public class SharedContent
{
public int Id { get; set; }
public ContentTypes ContentType { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
public class EntityA
{
public int Id { get; set; }
[ForeignKey("ContentId")]
public virtual SharedContent Content { get; set; }
public int ContentId { get; set; }
}
public class EntityB
{
public int Id { get; set; }
[ForeignKey("ContentId")]
public virtual SharedContent Content { get; set; }
public int ContentId { get; set; }
}
After executing below codes to get entityA from database entity framework fills all properties except entityA.Content! Whats wrong? What I need to get entityA with Content property?
var entityA = context.EntityA.Include(e => e.Content).ToList();