2012-09-11 25 views
0

我試圖理解爲什麼我得到這個錯誤:NHibernate的:自參照多對多配置問題

The relationship Client.ChildClients to Client.ChildClients has Inverse specified on both sides. Remove Inverse from one side of the relationship. 

我有一個包含這些特性的客戶實體:

public virtual Iesi.Collections.ISet ChildClients 
    { 
     get 
     { 
      return this._ChildClients; 
     } 
     set 
     { 
      this._ChildClients = value; 
     } 
    } 

    public virtual Iesi.Collections.ISet ParentClients 
    { 
     get 
     { 
      return this._ParentClients; 
     } 
     set 
     { 
      this._ParentClients = value; 
     } 
    } 

當我嘗試流利地配置映射時,出現上面列出的錯誤。 這是我這些屬性映射:

HasManyToMany<Client>(x => x.ChildClients) 
      .Access.Property() 
      .AsSet() 
      .Cascade.None() 
      .LazyLoad() 
      .Inverse() 
      .Not.Generic() 
      .Table("ParentClients_ChildClients") 
      .FetchType.Join() 
      .ChildKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1") 
                   .Nullable()) 
      .ParentKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId") 
                   .Nullable()); 
HasManyToMany<Client>(x => x.ParentClients) 
      .Access.Property() 
      .AsSet() 
      .Cascade.None() 
      .LazyLoad() 
      .Not.Generic() 
      .Table("ParentClients_ChildClients") 
      .FetchType.Join() 
      .ChildKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId") 
                   .Nullable()) 
      .ParentKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1") 
                   .Nullable()); 

我試圖找出我的問題,爲什麼它正在發生。我在這裏做錯了什麼?

+0

你必須添加'ForeignKeyConstraintNames'它沒有它不工作,我不知道爲什麼。請看這裏的工作示例:https://github.com/BrandyFx/Grapes/blob/master/src/Brandy.Grapes.FluentNHibernate/TreeEntryMap.cs – hazzik

+0

此外,可能你已經過時FluentNHibernate(我看到這個bug之前https:/ /github.com/jagregory/fluent-nhibernate/pull/88) – hazzik

回答

1

已解決here!這個問題似乎是流利的nhibernate驗證器或什麼的。希望我知道爲什麼這個修復它。