I have an existing NHibernate 2.1.2.4000 mapping that uses the mapping syntax:
<database-object>
<create>
CREATE VIEW View_Register AS ... (truncated for example)
</create>
<drop>
DROP VIEW View_Register
</drop>
</database-object>
When the database schema gets created, I use:
new SchemaExport(_configuration).Execute(true, true, false, aSession.Connection, tw);
The third parameter in the method above is ‘dropOnly’, which is obviously set to false.
In the past, my schema is created and the ‘View_Register’ is created successfully. Now, I’m re-running the schema generation, and the DROP is called at the beginning of the schema generation, but the CREATE is never called. I’ve confirmed this with multiple SQL profilers including the NH profiler.
Using explicit dialect declarations doesn’t seem to work either:
<dialect-scope name="NHibernate.Dialect.MsSql2000Dialect"/>
<dialect-scope name="NHibernate.Dialect.MsSql2005Dialect"/>
<dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/>
Any ideas folks?
Thanks,
David
I’m a complete idiot…
My View_Register mapping/view was completely fine, and was not my problem.
A different view was failing to create BEFORE View_Register because of a renamed table. Apparently, subsequent database-object/create calls are aborted on any ADO exception thrown by a previous create.
Good to know, but I feel silly for answering my own question!