views:

25

answers:

2

What is the best way to create Sql Server tables from business objects. For example I'm writing an application that has a user object to store user information. What's the best practice for creating tables from these objects? Create the objects first and then define the database or is there a tool to transform business objects into tables?

I'm just curious how others are doing this type of task. Thanks for your input!

+1  A: 

Use an ORM (object-relational mapping) tool, a list for tools for several languages can be found here: http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software

SQLMenace
...and fix it later? :-)
gbn
A: 

We are using NHibernate. It allows to write classes first, map them to the database by configuration (mapping files) and generate the database tables from that. It also allows restructuring the database (eg. for optimization) without touching business logic at all.

Of course, you still need to care about existing databases (schema migration).

There may be other ORM which have similar functionality. NHibernate is one of the most powerful.

Stefan Steinegger