Lately I've been looking into the .NET based ORMs that are available. I've noticed that each ends up siting in one or two camps. In one camp the database is created first, and the ORM provides an easier way to access the database in an application. In the second camp the object model exists first and the ORM facilitates persisting the object model in a database.
Now I'm not asking or asserting whether one camp is better then the other. I can certainly see reasons for each design methodology. What's frustrating me is out of all the tutorials and "getting started" documents I've read lately none just come out and say at the very beginning "this tool assumes you are starting with an existing database/object model". To me this is pretty fundamental to whether you would use one ORM vs another.
So after doing a bunch of reading, and created a couple "Hello World" projects I've put together a series of bullet points on the workflows supported by the ORMs I've looked into. Can anyone with experience with these tools tell me if I've made any incorrect statements, or completely missed any really important points. Specifically I'd really like to know if my assumptions about whether the database schema, or object model should come first with each tool are correct.
- Database should exist first
- Only works with SQL Server
- DataContext Class is used to read/write between classes and database
- DataContext can retun real physical classes, or dynamic types can be used to automatically create types based on database schema.
- Mapping defaults to mapping table names to class names, and property names to column names
- Mapping can be customized through attributes embedded in each class
- Database should be created first
- Works with a number of database technologies
- Classes are generated automatically from existing database schema using T4 templates
- Connection to database is totally transparent once classes are generated
- Calling class constructors automagicaly create records in database
- Changing property values automaticly updates database.
- Class structure should come first
- Works with a number of database technologies
- Repository class is created and connected to a database
- Database schema is created and updated automaticaly when classes are added to the repository
repo.Add<MyClass>(instance);
- Repository uses reflection to create/update database schema
- Create a table for each time, and a column for each property
- Either database or class structure can be created first
- Mapping may be created to match a new class structure to an existing database
- Mapping can be used to automatically generate the database schema
- Works with a number of database technologies
- Classes inside final assembly are attributed with NHibernate mapping settings which map classes and properties to tables and columns
- There are two methods to add mapping configuration
- XML files embeded in the binary,
<classname>.hbm.xml
- Attributes added to the code
- XML files embeded in the binary,
- Supports advanced mapping configuration including one to one, one to may, many to one, many to many, inheritance etc..l etc...