title: NHibernate Mapping: Save hierarchy to single table without discriminator
body: <p>I have a very extensible and modular application. I want to extend mapped Entites from other assemblies. Yet, I still need to operate on the base classes.</p>
  
  <p>Example:</p>
  
  <p>Parent class mapping in Assembly A:</p>
  
  <pre><code>    public class PersonMap : ClassMap&lt;Person&gt; 
      {
          public PersonMap()
          {
              Table("Persons");
  
              Id(x =&gt; x.Id).GeneratedBy.Assigned();
          }
  }
  </code></pre>
  
  <p>Child class mapping in Assembly B:</p>
  
  <pre><code>public class EmployeeMap : SubclassMap&lt;Employee&gt;
  {
      public EmployeeMap()
      {
          Table("Persons");
          Extends(typeof(Person));
  
          KeyColumn("Id");
  
          LazyLoad();
  
          HasMany&lt;Assignments&gt;(x =&gt; x.Assignments).KeyColumn("Id").Inverse().Cascade.AllDeleteOrphan().LazyLoad().NotFound.Ignore();
      }
  }
  </code></pre>
  
  <p>Now whenever I create a Person in some code of Assembly A it is saved as Employee by NHibernate. And that leads to a class cast exception due to proxying whenever I save a Person and try to refresh it in Assembly A. Assembly A must not have a dependency on Assembly B.</p>
  
  <p>I need to operate on the parent class in all methods of assembly A. The child class is only used in other assemblies. </p>
  
  <p>How can I map something like that? How can I tell NHibernate to just save it as the parent class? I use SaveOrUpdate to persist the entities; How can I correctly extend entities and yet save them to the same table without discriminator? Can't NHibernate differentiate by object type? Is there a workaround? </p>
  
  <p>I do not want to specify manual proxies as I'd have to create a proxy for every entity! I cannot use the visitor pattern due to dependency problems. </p>
  
  <p>I need a way to extend a mapped entity in a different assembly without such problems! The database is legacy, I cannot change it. How would you work around the issue?</p>