Fluent NHibernate - Create database schema only if not existing
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: public NhibernateSessionFactory(IPersistenceConfigurer config) { _sessionFactory = Fluently.Configure(). Database(config). Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>()). ExposeConfiguration(BuildSchema). BuildSessionFactory(); } private static void BuildSchema(Configuration config) { // if (DbExists(config)) // return; new SchemaExport(config).Create(false, true); } Note the " if (DbExists(config