static void

Database Schema Reader with codegen

Published Wednesday 26 January 2011

I've updated the Database Schema Reader CodePlex project with basic code generation.

The original code (vintage 2005) did all sorts of things like generating ADO data access classes and, over I added NHibernate mapping, Castle ActiveRecord, and Enterprise Library validation block attributes. It's old code (that is, ugly and horrible), so I stole bits of code and made it just do something a lot simpler.

Now it reads the table schema and turns them into simple POCO classes that are NHibernate compatible (virtual properties, override Equals and GetHashCode, composite keys are made into Key classes). There's also (simplistic) NHibernate mapping. And finally it has .Net 3.5's DataAnnotations for validation.

For quick and simple data-driven code, it's an okay starting point. It is just a starting point- not a data driven solution. There is a UI, but it's the most basic one I could design - it's certainly not anything like the Linq2Sql or EF designers (there are NHibernate mapping designers out there). But once you've got started in NHibernate you'll prefer to continue in code-first mode anyway.

If your database is a mess (I've seen a few with no primary keys .) it won't be much help!

Previously: TechEd Europe 2010 wrap up (13 Nov 2010)