NHibernate 映射通过约定继承模型映射

NHibernate mapping by convention inheritance model mapping

我正在尝试映射这个 class 结构:

public abstract class Entity
{
    public virtual Guid Id {get;set;}
    public virtual int Version {get;set;}
}

public class Parent: Entity
{
    public virtual string ParentName {get;set;}
    ... 
}

public class Child : Parent
{
    public virtual string DisplayName {get;set;}
    ... 
} 

我正在按照惯例进行映射,并混合使用如下代码进行映射:

public class ChildMappingOverride: UnionSubclassMapping<Child>
{

}

public class NHibernateMapping
{
    public void MapDomain()
    {
        ConventionModelMapper mapper = new ConventionModelMapper();
        Type baseEntityType = typeof(Entity);
        mapper.IsEntity((t, declared) => (baseEntityType.IsAssignableFrom(t) && baseEntityType != t) && !t.IsInterface);
        mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));

        mapper.Class<Entity>(map =>
            {
                map.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
                map.Version(x => x.Version, m => 
                {
                    m.Column("Version");
                    m.Generated(VersionGeneration.Never);
                    m.UnsavedValue(0);
                    m.Insert(true);
                    m.Type(new Int32Type());
                    m.Access(Accessor.Property);
                });
            }); 

        mapper.AddMapping<ChildMappingOverride>();
    }
} 

好的,现在当 nhibernate 创建数据库模式时,我得到 2 tables 而不是只有一个: Nhibernate 创建了 tables:父子。 我希望它只创建具有所有字段的 table 子项:Id、Version、ParentName、DisplayName。

我该怎么做? 请帮助

标记父级 class 摘要