title: NHibernate - one-to-one relationship
body: <p>I have a problem with one-to-one relationships in NHibernate. The structures of the my objects are as follows:</p>
  
  <pre><code>public partial class PersonDataContext
  {
      protected int _personid;
      protected string _name;
      protected EmployeeDataContext _employee;
  }
  
  
  
  public partial class EmployeeDataContext
  {
      protected int _personid;
      protected string _payrollno;
  }
  </code></pre>
  
  <p>In my model, every PersonDataContext must contain exactly one EmployeeDataContext, and every EmployeeDataContext that exists is there to be part of an PersonDataContext . It's a common one-to-one relationship.</p>
  
  <p>Now, to the mappings:</p>
  
  <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
      &lt;class name="PersonDataContext, DAL" table="`Person`" lazy="false"&gt;
          &lt;id name="PersonId" column="`PersonId`" type="int"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property type="string" name="name" column="`name`" /&gt;
          &lt;one-to-one name="Employee" cascade="save-update" class="EmployeeDataContext,DAL" /&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  
  
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
      &lt;class name="EmployeeDataContext, DAL" table="`Employee`" lazy="false"&gt;
          &lt;id name="PersonId" column="`PersonId`"&gt;
              &lt;generator class="foreign"&gt;
                  &lt;param name="property" &gt;PersonId&lt;/param&gt;
              &lt;/generator&gt;
          &lt;/id&gt;
          &lt;property type="string" length="30" name="PayRollNo" column="`PayRollNo`" /&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Then I create an PersonDataContext, that creates by itself an EmployeeDataContext. Then when I save it NHibernate throws an exception, <strong>"Unable to resolve property: PersonId".</strong></p>