This won't work in general. It could work only in case, that we've mapped the interface
(acting as abstract class in fact) already, e.g.: 8.1.1. Table per class hierarchy, An example:
<class name="IArticle" table="Articles">
...
<discriminator column="Discriminator" />
<subclass name="Article1" discriminator-value="Article1">
...
The Mapping-by-Code - inheritance:
public class ArticleBaseMap : ClassMapping<IArticle>
{
public ArticleBaseMap()
{
Discriminator(x =>
{
x.Column("discriminator");
subclasses:
public class Article1Map : SubclassMapping<Article1>
{
public Article1Map()
{
DiscriminatorValue("Article1");
...
Such a mapped hierarchy should not throw "Association references unmapped" any more. So, the mapping in this case, will require the referenced interface
or abstract/base class to be mapped - as hierarchy.
I would suggest, for clarity, to map the abstract class, to avoid confusion (that any implementation of IArticle
can be added to that Bag
). In fact, I do not see any advantage of mapping interfaces from the Buisness domain entities perspective.