答案 0 :(得分:0)
您仍然在模型中映射了外键(HeaderID)。你应该将HeaderID或Header作为属性,但不能同时作为属性。
从模型中删除它:
public class POSErrorQueueDetail
{
public virtual Int32 DetailID { get; set; }
public virtual POSErrorQueue Header { get; set; }
}
要访问HeaderID,只需访问Header.HeaderID即可。和映射:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="TPMControlPanel" namespace ="TPMControlPanel.Models">
<class name="POSErrorQueueDetail" table="POSErrorQueueDetails">
<id name="DetailID">
<generator class="identity" />
</id>
<!--all other property mappings removed for brevity -->
<many-to-one name="Header" class="POSErrorQueue" column="HeaderID" fetch="join" />
</class>
</hibernate-mapping>