Does anyone know a way to auto-generate database tables for a given class? I\'m not looking for an entire persistence layer - I already have a data access solution I\'m usi
I think for complex data types, you should extend them by specifying a ToDB() method which holds their own implementation for creating tables in the DB, and this way it becomes auto-recursive.
Try DaoliteMappingTool for .net. It can help you generate the classes. Download form Here
Subsonic is also another option. I often use it to generate entity classes that map to a database. It has a command line utility that lets you specify tables, types, and a host of other useful things
I know you're looking for an entire persistence layer, but NHibernate's hbm2ddl task can do this almost as a one-liner.
There is a NAnt task available to call it which may well be of interest.
You can do the opposite, database table to C# classes here: http://pureobjects.com/dbCode.aspx
Try out my CreateSchema extension method for objects at http://createschema.codeplex.com/
It returns a string for any object containing CREATE TABLE scripts.