Fluent nhibernate 使用fluent nhibernate映射引用(多个表)

Fluent nhibernate 使用fluent nhibernate映射引用(多个表),fluent-nhibernate,mapping,Fluent Nhibernate,Mapping,我试图使用Fluent NHIbernate来关注这篇文章: 我的测试生成以下错误: ----> NHibernate.MappingException : An association from the table TranslatedText refers to an unmapped class: .Domain.Localisation.ILocalizedEntity 你知道如何让NH尊重界面吗 将.IncludeBase()添加到我的自动模型没有任何作用。。。(正如所料,

我试图使用Fluent NHIbernate来关注这篇文章:

我的测试生成以下错误:

  ----> NHibernate.MappingException : An association from the table TranslatedText refers to an unmapped class: .Domain.Localisation.ILocalizedEntity
你知道如何让NH尊重界面吗

.IncludeBase()
添加到我的自动模型没有任何作用。。。(正如所料,这是一个界面,不是抽象的权利?)

(问题)

TranslatedText(has)
公共虚拟iLocalizeIdentity实体{get;set;}

mapping.ReferencesAny(tt => tt.Entity)
                .IdentityType<Guid>()
                .EntityIdentifierColumn("EntityId")
                .EntityTypeColumn("EntityType");
mapping.ReferencesAny(tt=>tt.Entity)
.IdentityType()
.EntityIdentifierColumn(“EntityId”)
.EntityType列(“EntityType”);
接口:

    public interface ILocalizedEntity
    {
        ICollection<TranslatedText> TranslatedTexts { get; set; }
    }
公共接口ILocalizedEntity
{
ICollection TranslatedTexts{get;set;}
}
我在FNH测试套件中也看到了同样的情况。我有一种感觉,这与我使用自动映射有关,但还不确定是什么

编辑 已确认-使用标准类映射而不是自动映射,使用上面相同的映射,工作正常

我确实找到了一个“解决办法”,即从自动映射中删除所涉及的类,并使用类映射手动滚动它们,这真的不理想,因为我喜欢自动映射

sessionFactory = Fluently.Configure()
 .Database(sqlConfig)
.Mappings(m => m.AutoMappings.Add(new MyAutoPersistenceModel().GetModel()))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<QuestionMap>())
.BuildSessionFactory();
sessionFactory=fluntly.Configure()
.Database(sqlConfig)
.Mappings(m=>m.AutoMappings.Add(新的MyAutoPersistenceModel().GetModel()))
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.BuildSessionFactory();
在MyAutoPersistenceModel中:

public override bool ShouldMap(System.Type type)
{
            var interfaces = type.GetInterfaces();
            return type != typeof(TranslatedText) && 
                !interfaces.Any(x => x.GetType() == typeof(ILocalisedEntity)) &&
                interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEntityWithTypedId<>));
}
public override bool ShouldMap(System.Type)
{
var interfaces=type.GetInterfaces();
返回类型!=typeof(TranslatedText)和
!interfaces.Any(x=>x.GetType()==typeof(ILocalisedEntity))&&
任何(x=>x.IsGenericType&&x.GetGenericTypeDefinition()==typeof(IEntityWithTypedId));
}
public override bool ShouldMap(System.Type type)
{
            var interfaces = type.GetInterfaces();
            return type != typeof(TranslatedText) && 
                !interfaces.Any(x => x.GetType() == typeof(ILocalisedEntity)) &&
                interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEntityWithTypedId<>));
}