SchemaUpdate for NHibernate

I was looking into how SchemaExport and SchemaUpdate work for NHibernate.Tool.hbm2ddl. I'm about to put another website up and I wanted to be able to generate the database schema for the new site, instead of creating the tables by hand. I've done this for a couple applications before, but I have to admit to only vaguely understanding how hbm2ddl works. This is probably do to the almost total lack of documentation on these features, outside of a quick run-down in the nhibernate docs .

At first glance it looks like Export generates SQL create table statements, and SchemaUpdate generates a bunch of update statements. But one thing I was curious about was whether or not SchemaUpdate would create new tables if they didn't exist. After looking at the current nhibernate source code, it appears that SchemaUpdate iterates through each table and if the table exists in the destination database then it generates an update script, otherwise it generates a create script.

Tags

First posted on 12/14/2014 1:14:19 AM