title: Fluent NHibernate - Create database schema only if not existing
body: <p>I have an application where I use Fluent Nhibernate to create my database. This far I've been recreating the database schema each time. The code that does this is this: </p>
  
  <pre><code>public NhibernateSessionFactory(IPersistenceConfigurer config)
  {
      _sessionFactory = Fluently.Configure().
          Database(config).
          Mappings(m =&gt; m.FluentMappings.AddFromAssemblyOf&lt;MappingsPersistenceModel&gt;()).
          ExposeConfiguration(BuildSchema).
          BuildSessionFactory();
  }
  
  private static void BuildSchema(Configuration config)
  {
      // if (DbExists(config))
      //    return; 
  
      new SchemaExport(config).Create(false, true);
  }
  </code></pre>
  
  <p>Note the "<code>if (DbExists(config))</code>". This is what I'd like to do. I'd like to create the schema only if it actually doesn't already exist. And in the next step - I'd like to update 
  it to be created if it isn't up to date. </p>
  
  <p>How do I achieve this? I am expecting a <code>config.DatabaseExists()</code>, but I can't see anything like this. I see some possibilities of a hacky solution, but what is the typical recommended way of handling this? </p>