I am trying to map following domain model using union-subclass strategy and FluentNHibernate. Here is how my classes look (with unneeded parts removed)
public class Benefit
{
}
public class Leave : Benefit
{
}
public class SeasonTicketLoan : Benefit
{
}
And here is my mapping code
public class BenefitMappings : ClassMap<Benefit>
{
public BenefitMappings()
{
UseUnionSubclassForInheritanceMapping();
}
}
public class LeaveMappings : SubclassMap<Leave>
{
}
public class SeasonTicketLoanMappings : SubclassMap<SeasonTicketLoan>
{
}
When I generate a database script using SchemaExport
for the above mapping, I get a table for Leave
and another one for SeasonTicketLoan
but none for Benefit
. Am I missing anything here?
Yes, you are using mapping Table Per Concrete Class (TPC), Which is intended to create
To get really deep and clear understanding, you should read this comprehensive article:
Inheritance mapping strategies in Fluent Nhibernate
Where you can read:
code snippet extract:
In case, we would like to have also table per base class(es), we need:
Table Per Type(TPT)
again some mapping snippet extract: