C# DuplicateMappingException:添加程序集时重复集合角色映射

C# DuplicateMappingException:添加程序集时重复集合角色映射,c#,.net,nhibernate,C#,.net,Nhibernate,我正在尝试创建多对一mapin,但在添加具有的文档程序集时失败 NHibernate.MappingException: “无法编译映射文档:TestForElma.Models.Person.hbm.xml” DuplicateMappingException:重复集合角色映射TestForElma.Models.Person.Documents 下面是hbm.xml文件 <?xml version="1.0" encoding="utf-8" ?

我正在尝试创建多对一mapin,但在添加具有的文档程序集时失败 NHibernate.MappingException:

“无法编译映射文档:TestForElma.Models.Person.hbm.xml” DuplicateMappingException:重复集合角色映射TestForElma.Models.Person.Documents

下面是hbm.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="TestForElma" namespace="TestForElma.Models">
  <class name="Document" dynamic-update="true" >
    <cache usage="read-write"/>
    <id name="Id" type="int">
      <generator class="native" />
    </id>
    <property name="Name" />
    <property name="CreationDate" />
    <property name="BinaryData" />
    <many-to-one name="Author" class="Person"
                 column="AuthorId" cascade = "save-update"/>
  </class>
</hibernate-mapping>


和nhibernate.cfg

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider
    </property>
    <property name="connection.driver_class">
      NHibernate.Driver.SqlClientDriver
    </property>
    <property name="connection.connection_string">
      Server=Local\SQLEXPRESS; database=DbName; Integrated Security=SSPI;
    </property>
    <property name="dialect">
      NHibernate.Dialect.MsSql2008Dialect
    </property>
  </session-factory>
</hibernate-configuration>

NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SqlClientDriver
Server=Local\SQLEXPRESS;数据库=DbName;综合安全=SSPI;
NHibernate.dialogue.mssql2008dialogue

它也不会在数据库中创建新表。

我开始使用Fluent Nhibernate,它可以正常工作

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="TestForElma" namespace="TestForElma.Models">
  <class name="Person" dynamic-update="true" >
    <cache usage="read-write"/>
    <id name="Id" type="int">
      <generator class="native" />
    </id>
    <property name="Name" />
    <property name="Password" />
    <bag name="Documents" inverse="true">
      <key column="AuthorId"/>
      <one-to-many class="Document"/>
    </bag>
  </class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider
    </property>
    <property name="connection.driver_class">
      NHibernate.Driver.SqlClientDriver
    </property>
    <property name="connection.connection_string">
      Server=Local\SQLEXPRESS; database=DbName; Integrated Security=SSPI;
    </property>
    <property name="dialect">
      NHibernate.Dialect.MsSql2008Dialect
    </property>
  </session-factory>
</hibernate-configuration>