私はグーグルとSOを精査しましたが、同じ問題を抱えている人に出会ったことはありません。これが私のモデルです:
public class Hierarchy
{
public virtual Event Prerequisite { get; set; }
public virtual Event Dependent { get; set; }
public override bool Equals(object obj)
{
var other = obj as Hierarchy;
if (other == null)
{
return false;
}
else
{
return this.Prerequisite == other.Prerequisite && this.Dependent == other.Dependent;
}
}
public override int GetHashCode()
{
return (Prerequisite.Id.ToString() + "|" + Dependent.Id.ToString()).GetHashCode();
}
}
これが私のマッピングです:
public class HierarchyMap : ClassMap<Hierarchy>
{
public HierarchyMap()
{
CompositeId()
.KeyReference(h => h.Prerequisite, "PrerequisiteId")
.KeyReference(h => h.Dependent, "DependentId");
}
}
そして、これが今までにない結果です:
{"The entity 'Hierarchy' doesn't have an Id mapped. Use the Id method to map your identity property. For example: Id(x => x.Id)."}
複合IDを有効にするために必要な特別な構成はありますか?私は最新のFNhを持っています(2012年6月29日現在)。
編集
CompositeIdを使用する代わりに、IDをマップし、2つのイベントを参照することにしたにもかかわらず、質問は未解決であると考えています。お気軽にご提案ください。