Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 关联引用未映射类异常_.net_Nhibernate - Fatal编程技术网

.net 关联引用未映射类异常

.net 关联引用未映射类异常,.net,nhibernate,.net,Nhibernate,我正在尝试将Northwind员工实体映射到NHibernate: public class Employee { public virtual int ObjectID { get; set; } public virtual string LastName { get; set; } public virtual string FirstName { get; set; } public virtual string Title { get; set; }

我正在尝试将Northwind员工实体映射到NHibernate:

public class Employee
{
    public virtual int ObjectID { get; set; }
    public virtual string LastName { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string Title { get; set; }
    public virtual string TitleOfCourtesy { get; set; }
    public virtual DateTime HireDate { get; set; }
    public virtual DateTime BirthDate { get; set; }
    public virtual string Address { get; set; }
    public virtual string City { get; set; }
    public virtual string Region { get; set; }
    public virtual string PostalCode { get; set; }
    public virtual string Country { get; set; }
    public virtual string HomePhone { get; set; }
    public virtual string Extension { get; set; }
    public virtual byte[] Photo { get; set; }
    public virtual string Notes { get; set; }
    public virtual string PhotoPath { get; set; }

    public virtual ISet<Employee> Subordinates { get; set; }
    public virtual Employee ReportsTo { get; set; }
}
公共类员工
{
公共虚拟int ObjectID{get;set;}
公共虚拟字符串LastName{get;set;}
公共虚拟字符串FirstName{get;set;}
公共虚拟字符串标题{get;set;}
公共虚拟字符串TitleOfCourtesy{get;set;}
公共虚拟日期时间HireDate{get;set;}
公共虚拟日期时间出生日期{get;set;}
公共虚拟字符串地址{get;set;}
公共虚拟字符串City{get;set;}
公共虚拟字符串区域{get;set;}
公共虚拟字符串PostalCode{get;set;}
公共虚拟字符串国家{get;set;}
公共虚拟字符串HomePhone{get;set;}
公共虚拟字符串扩展名{get;set;}
公共虚拟字节[]Photo{get;set;}
公共虚拟字符串注释{get;set;}
公共虚拟字符串光路{get;set;}
公共虚拟ISet从属项{get;set;}
公共虚拟员工报告{get;set;}
}
映射:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true" namespace="NHibernateTests.Data" assembly="NHibernateTests">
  <class name="Employee" lazy="false" entity-name="Employees">
    <id name="ObjectID" access="property" column="EmployeeID" >
      <generator class="native" />
    </id>
    <property name="LastName" access="property" column="LastName"/>
    <property name="FirstName" access="property" column="FirstName"/>
    <property name="Title" access="property" column="Title"/>
    <property name="TitleOfCourtesy" access="property" column="TitleOfCourtesy"/>
    <property name="BirthDate" access="property" column="BirthDate"/>
    <property name="HireDate" access="property" column="HireDate"/>
    <property name="Address" access="property" column="Address"/>
    <property name="City" access="property" column="City"/>
    <property name="Region" access="property" column="Region"/>
    <property name="PostalCode" access="property" column="PostalCode"/>
    <property name="Country" access="property" column="Country"/>
    <property name="HomePhone" access="property" column="HomePhone"/>
    <property name="Extension" access="property" column="Extension"/>
    <property name="Photo" access="property" column="Photo"/>
    <property name="Notes" access="property" column="Country"/>
    <property name="PhotoPath" access="property" column="PhotoPath"/>

    <set name="Subordinates" table="Employees" access="property" lazy="false" inverse="true">
      <key column="ReportsTo"/>
      <one-to-many class="Employee" />
    </set>

    <many-to-one name="ReportsTo" column="ReportsTo" access="property" not-null="false"/>
  </class>
</hibernate-mapping>

我不断得到“关联引用未映射类:NHibernateTests.Data.Employee”映射异常。 它可以很好地处理注释掉的自关联部分(下属和报告)


我的映射有什么问题?

愚蠢的错误:使用实体名称而不是表属性。

有时,当我们没有为特定的
HBM
文件设置属性时,会出现上述错误。 因此,转到您的
hbm
文件属性并选择

BuildAction = EmbeddedResource

我已经在Nhibernate环境下测试了这个场景,wpf。

我遇到了同样的错误,这导致了很多麻烦。所以我只想添加我的解决方案,以防其他人有相同的问题

我在关系中引用的实体是
抽象的
,这是一个愚蠢的复制/粘贴错误的结果。有一次我拿出了
摘要
,它执行得很好