title: Fluent NHibernate HasMany Foreign Key Mapping Problem
body: <p>I'm trying to map a simple data structure in nhibernate</p>
  
  <p><strong>Tables:</strong></p>
  
  <pre><code>Employees
  employeeID int
  username varchar(30)
  departmentID int
  
  Departments
  departmentID int
  deptName varchar(50)
  </code></pre>
  
  <p>My department mapping is like so:</p>
  
  <pre><code>public class DepartmentMap: ClassMap&lt;Department&gt;
  {
      public DepartmentMap()
      {
          Id(m =&gt; m.DepartmentID).Column("departmentID");
          Map(m =&gt; m.DepartmentName).Column("deptName").Length(50);
  
          HasMany(m =&gt; m.Employees);
  
          Table("Departments");
      }
  }
  </code></pre>
  
  <p>... and the employee mapping</p>
  
  <pre><code>public class EmployeeMap : ClassMap&lt;Employee&gt;
  {
      public EmployeeMap()
      {
          Id(x =&gt; x.EmployeeID, "employeeID");
          Map(x =&gt; x.UserName, "username").Length(30);
  
          References&lt;Department&gt;(x =&gt; x.Department, "departmentID");
  
          Table("Employees");
      }
  }
  </code></pre>
  
  <p>I'm trying to loop through departments and pull all employees from each department:</p>
  
  <pre><code>foreach (var i in _directoryData.DepartmentCollection)
  {
      foreach (var e in i.Employees)
      {
          Debug.WriteLine(i.DepartmentName + " " + e.UserName);
      }
  }
  </code></pre>
  
  <p>which gives me an error stating "<code>Invalid column name 'Department_id'.</code>" ... and in the generated query it uses department_id as well. When I just loop through departments and output the department name it works fine.</p>
  
  <p>Any idea what I'm missing to get the correct column name for departmentID? Here are my model objects just in case:</p>
  
  <pre><code>public class Department
  {
      public virtual int DepartmentID { get; set; }
      public virtual string DepartmentName { get; set; }
  
      public virtual ICollection&lt;Employee&gt; Employees { get; set; }
  }
  
  public class Employee : PersistentEntity
  {
      public virtual int EmployeeID { get; set; }
      public virtual string UserName { get; set; }
  
      public virtual Department Department { get; set; }
  }
  </code></pre>