There are plenty of ORM Frameworks available to use and I have tried few of them. In this post I will describe my experience with those frameworks.
NHibernate:
NHibernate was the first ORM framework that I tried. The real power of this framework is that it supports many different kinds of databases. The bad thing which pushed me away was the complicated XML mapping and lazy loading. I was never able to get lazy loading to work properly. I searched on forums and saw many other developers facing the same problem with no solution.
Castle Active Record:
Few days ago I started with the Castle Active Record Framework which was built on top of NHibernate framework. The framework allows you to decorate your class and properties with attributes. One of the things I disliked about the Active Record was that I had to tell the framework the name of the primary key in the database if it was different from the property name. The following code will not work if the name of the primary key column in the database is DepartmentID.
[PrimaryKey]
public int Id
{
get { return _id; }
set { _id = value; }
}
In my opinion the framework should be smart enough to infer the column names itself especially if the column is a primary key column. I can get the above example to work property using the following code:
[PrimaryKey(Column="DepartmentID")]
public int Id
{
get { return _id; }
set { _id = value; }
}
Another thing is how to specify the auto-generated columns. I have columns like DateCreated and DateModified where values are automatically generated at the database level. The framework should be smart enough to know that. I am still not sure how to tell the framework that these properties are automatically generated.
[Property]
public DateTime DateModified
{
get { return _dateModified; }
set { _dateModified = value; }
}
LINQ to SQL:
LINQ to SQL framework is a product of Microsoft and hence it only supports SQL SERVER out of the box. But if you search Google you will find that there are many different flavors of LINQ to [Something] available. LINQ to SQL is very quick to setup and get started. The biggest problem is that your application cannot be layered properly. The framework is designed with RAD development in mind and therefore is difficult to follow the 3-layer architecture. The designer is also little immature and lacks some basic features. Also, if you try to create a 3-layer application then you will also run into the problem if object lifetime and connection with the DataContext.
For some reason it feels like although there are many different frameworks available. Each of them lacks in some way which pushes the developer away.