title: Nhibernate mapping a class which has a generic list property
body: <p>I am new to Nhibernate and I am trying to map a class (Invoice) which has a generic list property using Nhibernate but I keep getting
  error: "An association from the table InvoiceDetails refers to an unmapped class: System.Int32".
  Because each invoice has more details I have tought of one to many relation between Invoices and InvoiceDetails table.</p>
  
  <p>Details:
  a) Invoice class:</p>
  
  <pre><code>public class Invoice
  {
      private IList&lt;InvoiceDetail&gt; _invoiceDetails = new List&lt;InvoiceDetail&gt;();
  
      public virtual int InvoiceID { get; set; }
      public virtual string SerialNumber { get; set; }
      public virtual string Number { get; set; }
      public virtual DateTime InvoiceDate { get; set; }
      public virtual decimal Amount { get; set; }
      public virtual IList&lt;InvoiceDetail&gt; InvoiceDetails
      {
          get { return _invoiceDetails; }
          set { _invoiceDetails = value; }
      }
      public virtual Customer customer { get; set; }
      public virtual Institution Institution { get; set; }
      public virtual Receipt receipt { get; set; }
      public virtual bool IsDeleted { get; set; }
  }
  </code></pre>
  
  <p>b) InvoiceDetail class:</p>
  
  <pre><code>public class InvoiceDetail
  {
      public virtual int InvoiceDetailID { get; set; }
      public virtual int InvoiceID { get; set; }
      public virtual string ServiceDescription { get; set; }
      public virtual string Unit { get; set; }
      public virtual int Quantity { get; set; }
      public virtual double Value { get; set; }
      public virtual bool IsDeleted { get; set; }
  }
  </code></pre>
  
  <p>c) Invoice mapping file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
      assembly="MyProject" namespace="MyProject.Model"&gt;
      &lt;class name="Invoice" table="Invoices"&gt;
          &lt;id name="InvoiceID" column="InvoiceID" type="int"&gt;
              &lt;generator class="native"&gt;&lt;/generator&gt;
          &lt;/id&gt;
          &lt;property name="SerialNumber" column ="InvoiceSerialNumber"/&gt;
          &lt;property name="Number" column ="InvoiceNumber"/&gt;
          &lt;property name="InvoiceDate"/&gt;
          &lt;property name="Amount"/&gt;
          &lt;property name="IsDeleted" /&gt;
          &lt;many-to-one name="Institution" column="InstitutionID" /&gt;
          &lt;bag name="InvoiceDetails" access="nosetter.camelcase"
              inverse ="true" lazy ="false" cascade="all-delete-orphan"&gt;
              &lt;key column="InvoiceID"/&gt;
              &lt;many-to-one class="MyProject.Model.InvoiceDetail, MyProject"/&gt;
          &lt;/bag&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>d) InvoiceDetail mapping file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
      assembly="MyProject" namespace="MyProject.Model"&gt;
      &lt;class name="InvoiceDetail" table="InvoiceDetails"&gt;
          &lt;id name="InvoiceDetailID" column="InvoiceDetailID" type="int"&gt;
              &lt;generator class="native"&gt;&lt;/generator&gt;
           &lt;/id&gt;
           &lt;many-to-one name="InvoiceID" column="InvoiceID" /&gt;
           &lt;property name="ServiceDescription"/&gt;
           &lt;property name="Unit"/&gt;
           &lt;property name="Quantity"/&gt;
           &lt;property name="Value"/&gt;
           &lt;property name="IsDeleted" /&gt;    
       &lt;/class&gt;
   &lt;/hibernate-mapping&gt;
  </code></pre>