如何在 NHibernate ManyToOne 代码映射中设置实体名称?

How to set entity name in NHibernate ManyToOne code mapping?

更新:Fixed in version 5.2.


我正在将一堆 NHibernate .hbm.xml 映射转换为代码映射。有几个 many-to-one 元素具有 entity-name 属性:

<many-to-one name="Foo" column="FooId" class="Bar" entity-name="BarEntity"/>

应该翻译成:

ManyToOne( c => c.Foo, map => 
{
     map.Column("FooId");
     map.EntityName("BarEntity"); // error
}

不幸的是,这不起作用,因为 IManyToOneMapper 中没有 EntityName。为什么? IManyToManyMapperIOneToManyMapper 都有 EntityName.

我该如何解决这个问题?除了保留 .hbm.xml 映射之外,还有其他解决方法吗?

我想它只是被遗忘了。我刚刚检查了 4.0.2 源,但没有找到任何东西。实际使用实体名称的人并不多,因此可能直到现在才提出要求。

我建议在 jira 中输入功能请求。您可能想自己实现并提供给社区。