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());
我試圖找出我的問題,爲什麼它正在發生。我在這裏做錯了什麼?
你必須添加'ForeignKeyConstraintNames'它沒有它不工作,我不知道爲什麼。請看這裏的工作示例:https://github.com/BrandyFx/Grapes/blob/master/src/Brandy.Grapes.FluentNHibernate/TreeEntryMap.cs – hazzik
此外,可能你已經過時FluentNHibernate(我看到這個bug之前https:/ /github.com/jagregory/fluent-nhibernate/pull/88) – hazzik