Wednesday, 21 January 2009

NHibernate and schema creation/update

A colleague of mine today enlightened me about one of the features in NHibernate that lets you completely ignore the whole issue of managing and updating database schema. You can use NH mappings to define the entire schema and let NH worry about creating the database and updating between the different versions.

Back in the day I used to build data first, designing ERDs and sprocs before writing any code, and so I was a little worried about indexing, constraints, naming foreign keys and such like, but the schema is more than capable of articulating this too.

Tying this up with Fluent NHibernate, strongly typed mapping files / auto map and you have a very powerful, quick to implement platform for domain driven data access.

Here's an article that tells you all about it better than I can;