title: Nhibernate hbm to Fluent
body: <p>I have a requirement to write the mapping using Nhibernate fluent.</p>
  
  <p>I have the following in hbm </p>
  
  <pre><code>&lt;class name="XYZ" table="Some_Table"&gt;
      &lt;composite-id&gt;
        &lt;key-many-to-one name="A" column="A_ID"/&gt;
        &lt;key-property name="Term" type="Some_Assembly"&gt;
          &lt;column name="YEAR"/&gt;
          &lt;column name="MONTH"/&gt;
        &lt;/key-property&gt;
      &lt;/composite-id&gt;
      &lt;property name="P" column="P"/&gt;
    &lt;/class&gt;
  </code></pre>
  
  <p>and I would need to rewrite this in fluent. the main reason is that we are moving away from hbm files to fluent.</p>
  
  <p>so far I have the following</p>
  
  <pre><code> public class XYZMap: ClassMap&lt;XYZ&gt;
      {
          public XYZMap()
          {
              Table("Some_Table");
  
              CompositeId()
                  .KeyProperty(x=&gt; x.Term, set =&gt;
                  {
                      set.ColumnName("Year");
                      set.ColumnName("Month");
                      set.Type(typeof(Some_Assembly));
                  })
                  .KeyProperty(x=&gt; x.A, set =&gt;
                  {
                      set.ColumnName("A");
                      set.Type(typeof (Other_Assembly));
                  });
  
  
  
              Map(x=&gt; x.P, "P");
          }
      }
  </code></pre>
  
  <p>But I am getting the following error</p>
  
  <pre><code>X.Y.TestZ.PostCreate:
  SetUp : Autofac.Core.DependencyResolutionException : An exception was thrown while executing a resolve operation. See the InnerException for details.
    ----&gt; FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
  
  
    ----&gt; NHibernate.MappingException : Could not compile the mapping document: (XmlDocument)
    ----&gt; NHibernate.MappingException : Could not determine type for: Other_Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(A_ID)
  </code></pre>
  
  <p>I think I am unable to map many-to-one when I am trying to configure using fluent.</p>
  
  <p>So can someone please help.</p>