I'm using NHibernate mappings as a defining schema for my app in the development phase and for the schema definition I'm using the NHibernate.Tool.hbm2ddl.SchemaExport()
method to generate a createscript.
Now, I have considered using the Configuration.GenerateSchemaUpdateScript()
method to generate database changescripts like this:
var dialect = Dialect.GetDialect(configuration.Properties);
string[] schemaUpdateScript;
using (var conn = new SqlConnection(
configuration.GetProperty("connection.connection_string")))
{
conn.Open();
schemaUpdateScript = configuration.GenerateSchemaUpdateScript(dialect,
new DatabaseMetadata(conn, dialect));
}
After this I'll save the schema update script to timestamp-named script-files.
Is this a good way to manage schema changes in NHibernate?
Are there any major drawbacks?