2012-05-14 115 views
1

我最近通過NuGet從1.3.0.717和3.2.0.4000更新了我的項目到FNH 1.3.0.727和NH 3.3.0.4000。使用自動地圖,之前生成的XML更新如下所示:流利的NHibernate的自動映射參考鍵

<class xmlns="urn:nhibernate-mapping-2.2" name="APP.Domain.Module, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="Module"> 
    <id name="Id" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="ModuleId" /> 
     <generator class="guid.comb" /> 
    </id> 
    <many-to-one class="APP.Domain.Product, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Product"> 
     <column name="ProductId" /> 
    </many-to-one> 
    <joined-subclass name="APP.Domain.Audit.Trail, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> 
     <key> 
     <column name="TrailId" /> 
     </key> 
     <bag cascade="all" inverse="true" lazy="true" name="Arguments"> 
     <key> 
      <column name="TrailId" /> 
     </key> 
     <one-to-many class="APP.Domain.Audit.Argument, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
     </bag> 
     <property name="Action" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Action" /> 
     </property> 
     <property name="Date" type="System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Date" /> 
     </property> 
     <property name="Workflow" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Workflow" /> 
     </property> 
     <property name="Identity" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="[Identity]" /> 
     </property> 
    </joined-subclass> 
    </class> 

和更新後:

<class xmlns="urn:nhibernate-mapping-2.2" name="APP.Domain.Module, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Module`"> 
    <id name="Id" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="ModuleId" /> 
     <generator class="guid.comb" /> 
    </id> 
    <many-to-one class="APP.Domain.Product, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Product"> 
     <column name="ProductId" /> 
    </many-to-one> 
    <joined-subclass name="APP.Domain.Audit.Trail, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> 
     <key> 
     <column name="TrailId" /> 
     <column name="ModuleId" /> 
     </key> 
     <bag cascade="all" inverse="true" lazy="true" name="Arguments"> 
     <key> 
      <column name="TrailId" /> 
      <column name="TrailId" /> 
     </key> 
     <one-to-many class="APP.Domain.Audit.Argument, APP.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
     </bag> 
     <property name="Name" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Name" /> 
     </property> 
     <property name="Date" type="System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Date" /> 
     </property> 
     <property name="Workflow" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="Workflow" /> 
     </property> 
     <property name="Identity" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <column name="[Identity]" /> 
     </property> 
    </joined-subclass> 
    </class> 

有在我的模型沒有組合鍵,一切是正確的,現在我剛開例外"Foreign key (FK4B9386BFF4D27734:Argument [TrailId])) must have same number of columns as the referenced primary key (Trail [TrailId, ModuleId])"

我錯過了新版本的東西嗎?

回答

0

使用IReferenceConvention改爲覆蓋ForeignKeyconvention類中的GetKeyName解決了問題。

0

該問題駐留在約定和覆蓋的組合中。以前的版本在每種情況下都會正確覆蓋關鍵列(外部,加入,hasmany,manytomany等),但現在正在添加它們。錯誤?