Create Sql Database Tables from Business Objects
What is the best way to create Sql Server tables from business objects. For example I'm writing an application that has a use开发者_JAVA百科r 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.
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
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.
精彩评论