If you want to use HNibernate to handle a SQL Server 2005 database without the default dbo schema, you'll have to do 2 things. First, you'll have to change the schema in your model mapping file(s):

  1. <hibernate-mapping
  2. xmlns="urn:nhibernate-mapping-2.2"
  3. schema="Zen">
  4. ...
  5. </hibernate-mapping>

Then, you can generate the SQL scripts to build the database structure, using:

  1. SchemaExport exporter;
  2. exporter = new SchemaExport(NHibernateConfig);
  3. exporter.SetOutputFile("CreateDB.sql");
  4. exporter.Create(true, true);

But... the exporter won't create the schema for you... you'll have to do it yourself, by running:

  1. CREATE schema Zen

If you run this before the CreateDB.sql, everything will work fine.