title: Fluent NHibernate: do not generate any mapping for class during SchemaExport
body: <p>I've got an application talking to two databases, and it runs fine, and my tests pass, except when it tries to export the current DB schema, it outputs everything for both DBs in one block, and when it tries to validate the object model / DB schema line up, it tries to look in one database for everything, when one class (which is external data, hence the foreign DB) should not be mapped. I provided a mapping override for the class so that NH can correctly load/use data from the foreign DB (it's read-only), but now when I export my schema, it tries to make that table.</p>
  
  <p>I tried <code>IgnoreBase(typeof(Unit))</code> but this has no effect (whereas <code>IgnoreBase(typeof(Entity))</code> does work correctly). I have decorated the custom repository methods with <code>[SessionFactory(DataGlobals.FOREIGN_DB_FACTORY_KEY)]</code> where that simply defines a constant string to use as a key for the <code>SessionFactory</code>, but I'm sure if there's something I need to decorate the class (<code>Unit</code>) with or pass a different parameter to <code>SchemaExport</code> ... </p>
  
  <pre><code>public void CanGenerateDatabaseSchema(){ 
  var session = NHibernateSession.GetDefaultSessionFactory().OpenSession();
  
          using (TextWriter stringWriter = new StreamWriter("../../../../db/schema/UnitTestGeneratedSchema.sql"))
          {
              new SchemaExport(configuration).Execute(true, false, false, session.Connection, stringWriter);
          }
  }
  
  public void CanConfirmDatabaseMatchesMappings()
      {
          var allClassMetadata = NHibernateSession.GetDefaultSessionFactory().GetAllClassMetadata();
  
          foreach (var entry in allClassMetadata)
          {
              NHibernateSession.Current.CreateCriteria(entry.Value.GetMappedClass(EntityMode.Poco))
                   .SetMaxResults(0).List();
          }
      }
  </code></pre>