Monday, February 14, 2011

How Generate Database from NHibernate mapping files

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    ...
    <session-factory>
        ...
        <property name="hbm2ddl.auto">create</property>
    </session-factory>
    ...
</hibernate-configuration>

If you define <property name="hbm2ddl.auto">create</property> in session-factory section of NHibernate configuration database schema would be generated for you by NHibernate. But you still have to create empty database before that.