I have the following problem. I'm building TPH inheritance with Entity Framework and I need to set discriminator column on existing property of subclass. Example:
public abstract class Building
{
//... some properties
public BuildingType BType { get; set; } // sub class with discriminator property
}
public class BuildingA : Building
{
}
public class BuildingB : Building
{
}
public class BuildingType
{
//... some properties
public string Category { get; set; }
/*
discriminator property
if this property is set to "A" then the building is type BuildingA
and if is set to "B" then the building is type BuildingB
*/
}
So - every building has required the BuildingType property and the BuildingType class has the property Category (which already exists) and which can be disciminator for the buildings TPH inheritance. How can I achieve this?