views:

123

answers:

1

I am using SchemaUpdate to make changes to the database based on some configuration. It works fine when new tables or columns are added. However, it does not work when columns are deleted or tables are dropped. The mapping file does reflect these changes, but the SchemaUpdate does not seem to recognize this. I don't want to drop the tables and recreate them, as I want the data to be retained.

Does anyone know if this 'Delete and Drop' functionality is supported by SchemaUpdate?

Thanks

A: 

It is not - SchemaUpdate will only add new tables/columns. This behavior is by design - your model can (for example) be mapped on a database that is used by many systems, and it could only use a subset of tables/columns. In that case, if SchemaUpdate did drop those columns and tables - it would break all those other systems.

See http://stackoverflow.com/questions/933327/nhibernate-schemaupdate for alternatives.

maciejkow