First I have a base class like this:
public class BaseModel
{
public string Information { get; set; }
}
Then I have two sub classes of the base class :
public class SubType1 : BaseModel
{
public int Id { get; set; }
public int TestData1 { get; set; }
public int ParentId { get; set; }
public virtual Parent Parent { get; set; }
}
public class SubType2: BaseModel
{
public int Id { get; set; }
public string TestData2 { get; set; }
public int ParentId { get; set; }
public virtual Parent Parent { get; set; }
}
Then I have a parent class that has a list of the base class :
public class Parent
{
public int Id { get; set; }
public virtual List<BaseModel> Components { get; set; } = new List<BaseModel>();
}
The Parent entity has many SubType1 s and then also many SubType2 s
SubType1 and SubType2 each have their own table
What is some fluent I could add that would automatically make the Components list on the Parent entity return all entites from the SubType1 and SubType2 tables?
Key requirement : Needs to be in fluent
According to your description, it seems that you are using the Table per Concrete Type (TPC) , right?
As far as I know, in the EF core, the TPC pattern is currently on the backlog , which means that it is being considered for inclusion as a feature, but no date has been set as yet.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.