This post was originally posted here
NHibernate provides a number of tools for developers to manage their database. I prefer mapping driven approach in which I let NHibernate generate the schema for database for me. By that way, I only concentrate on my domain. For me, database is not the center but only a tool for storage most of the cases.
This approach is valid only for greenfield projects. If you’re using a legacy database, however, things get more complicated and you write your mappings according to your database.
NHibernate now(with revision 3918, which means you have to use trunk until we release it) provides a way to verify your mappings against your database.
The usage is similar to other tools
I won’t write a dedicated code for this but rather I am going to copy the tests from the code itself.
SchemaValidator has a single method called Validate. You give it the configuration and it validates the schema.