I use NHibernate mappings as the defining schema for my application during the development phase, and I use the method NHibernate.Tool.hbm2ddl.SchemaExport()to create the generated file to define the schema .
Now I looked at using the method Configuration.GenerateSchemaUpdateScript()to create database change scripts as follows:
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 that, I save the script schema update to timestamp-named script -files.
Is this a good way to manage schema changes in NHibernate?
Are there any significant flaws?
source
share