title: Fluent nhiberante mapping for legacy tables
body: <p>How to define fluent nhibernate mapping for the Legacy tables.</p>
  
  <p>I have four table</p>
  
  <ol>
  <li>CTType(<strong>id</strong> GUID, <strong>Name</strong> varchar(100), <strong>DateOFbirth</strong> datetime)</li>
  <li>CTType_Legacy(<strong>id</strong> GUID, <strong>CTType_Legacy_id</strong> identity int)</li>
  <li>CTTypeMap(<strong>id</strong> GUID, <strong>createdOn</strong> datetime, <strong>CtType_id</strong> guid)</li>
  <li>CTTypeMap_Legacy(<strong>id</strong> GUID, <strong>CT_Type_id</strong> int)</li>
  </ol>
  
  <p>Info</p>
  
  <ul>
  <li>The first two tables have fixed 50 records. These tables are populated first time when the database is configured for a client.</li>
  <li>For the first two table IDs is mapping column(primary-forign key).</li>
  <li>The last two tables CtType_id is mapped to Id column of CTType table</li>
  </ul>
  
  <p>From the UI when the user saves a new CTTypeMapObject it inserts record into CTTypeMap table. The mapping is defined as:</p>
  
  <pre><code>public class CTTypeMapMap :Enity&lt;CTTypeMap&gt;
  {
      Public CTTypeMapMap()
      {
          Id(x =&gt; x.ID);
          Map(x =&gt; x.createdOn);
          References(x = x.CtType);
  
          Join("CTTypeMap_Legacy", join =&gt;
          {
              join.KeyColumn("Id");
              join.Map(x =&gt; x.CTTypeMap).Column("CT_Type_id");  //not working
          });
      }
  }
  </code></pre>
  
  <p>The value for the column <strong>CT_Type_id</strong> of table <strong>CTTypeMap_Legacy</strong> should be <strong>CTType_Legacy_id</strong> column value of <strong>CTType_Legacy</strong>. I am not able to insert the correct value into <strong>CT_Type_id</strong> of table <strong>CTTypeMap_Legacy</strong>.</p>
  
  <p>Could someone please let me know how to do the mapping on the line highlighted with the comment?</p>