我已经搜索了 Google 和 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 日)。
编辑
即使我决定映射一个 Id 并引用 2 个事件而不是使用 CompositeId,我仍然认为这个问题是开放的。随意提出答案。