Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

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.

Posted on Monday, May 12, 2008 5:30 AM | Back to top


Comments on this post: On a Quest to find a better ORM Framework

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
You should check out LLBLGen Pro. It is the best OR/M for this style of mapping where you start with the DB first and then generate the classes IMO.

If you want to go the other way, from domain classes to DB then go NHibernate. NHibernate is frustrating to use if you already have the db schema intact.

LLBLGen has the best 3rd party linq provider out there and the features are light years ahead of linq to SQL. I would recommend to only use LLBL Generated entities for data access though, not expose them into your upper layers as their default guidance suggest. But you probably know that already =)
Left by steveF on May 12, 2008 9:28 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
I don't have any direct experience with the Castle project, but I've used ActiveRecord as implemented in Rails. The thing that I dislike about the Rails Way is all the "magic" that it does. It's easy to loose track of what's connected to what.

I'd much rather be explicit about mapping that isn't exactally what you expect. The problem is not really what you expect, because you are working on it right now. The problem is what the next developer expects.

Left by David on May 12, 2008 10:12 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
Nice review.

Take a look at Subsonic? subsonicproject.com

It is pretty nice also.
Left by SH on May 12, 2008 11:24 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
Dig throught he NHibernate documentation. (just google NHibernate Reference) The mappings are complicated and unintuitive... but once you get the hang of them, NHibernate's very powerful and flexible.

Also consider using ActiveWriter to create your mappings based on your schema until you get the hang of it.
Left by ignu on May 19, 2008 7:39 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
Try http://www.easyobjects.net/ if you like Enterprise Library and 3 tier architecture.
Left by GiMi on May 19, 2008 7:49 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
Did you try SubSonic?
Left by Nick on May 20, 2008 9:46 AM

# re: On a Quest to find a better ORM Framework
Requesting Gravatar...
Look at EntitySpaces(http://www.entityspaces.net/Portal/Default.aspx)
It works good for me.
Left by Michael Freidgeim on May 27, 2008 1:06 AM

Your comment:
 (will show your gravatar)


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net