By implementing ISubclassConvention, I can change the Discriminator Value for the subclasses in my class hierarchy. I'm now looking for a way to set the Discriminator Value for my base classes as well. Is there a way to change it with a convention override or do I have to add a manual mapping for my hierarchy?
(The IClassConvention provides the DiscriminatorValue property but it is read-only, so no luck there.)
The only way I know is to make simple mapping override just for base class.
public class DepotMappingOverride : IAutoMappingOverride<Depot>
{
/// <summary>
/// Alter the auto mapping for this type
/// </summary>
/// <param name="mapping">Auto mapping</param>
public void Override(AutoMapping<Depot> mapping)
{
mapping.DiscriminateSubClassesOnColumn("Type", "BaseDepot");
}
}
Now "BaseDepot" will be discriminator value for Depot class.