Comparing ORM's

by jmorris 12/25/2009 6:33:00 PM

I am currently using Linq, EF, ADO.NET and NHibernate (trying at least) in various projects. Here is my current feeling about each:

  • Linq2Sql - easy, works, obsolete, lacks many features...
  • EF- easy, fast, low barrier to entry...Linq tooling is better than v3.5, which is pretty much useless...v4 seems better
  • ADO.NET - simple, easy, no hidden "gotchas", repetitious, flexible...in most all cases requires framework built around it to scale developer-wise
  • NHibernate - flexible, complex, high barrier to entry, lots of hidden "gotchas" regarding performance, mappings, etc., poor (IMO) query API (syntax), outdated documentation, dedicated community albeit scattered

When one say's NHibernate is missing VS integration, I don't think it's the GUI Modeler that they are missing. It's the fact that they can't point at a database and hit "GO"...I think model first is important, but not everyone works that way.

Low friction prototypes are often the start to more complex finished products. We don't need complexity in prototypes; we tailor our finished works to our problem domain - this is where we tweak the API (away from the GUI) to fit the specific requirements of our problem. The ability to quickly create prototypes from the IDE is incredibly important. Without IDE integration, creating these prototypes is difficult...friction.

The thing that a MS solution offers is IDE integration, which you do not find in the NHibernate suite. If I could go to the NHForge.com site and download a VS plug-in, point at a db, and then start playing...I would be much more inclined to use NHIbernate in a project.

This post was motivated by this post...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

NHibernate | ORM | Linq | EF

Fluent NHibernate Mapping Identity Columns to Properties

by jmorris 11/30/2009 3:37:00 PM

I decided to jump into the NHibernate lovefest and use it in an upcoming project that I am planning right now. I have been following the NHibernate project for some years, but never actually comitted to using it in a project, because frankly, it was a bit intimidating in size and complexity. Now, of course this was my biased assumption and boy was I wrong! The new Linq 2 NHibernate and Fluent NHibernate API's are awesome and relatively simple to get up and running.

Although I still have some reservations about the completeness and performance of Linq 2 Hibernate, Fluent NHibernate seems to be pretty mature. Additionally, the Fluent NHibernate community is robust, friendly and very quick to lend a hand when I ran into some trouble with AutoMapping.

AutoMapping is a convention based feature of Fluent NHibernate in which with a very little configuration, you can map your entire schema to your domain model. This feature is a tremendous time saver, and gives the illusion of "it just works"! As awesome AutoMapping is, there are certain situations where it will choke. In these cases you must add a little "help" to make the mapping work correctly. Take the following table:

 


Just your basic Role table, but notice how the primary key column is named [entity name]+Id: RoleId? This is a convention that I use for naming the primary keys of all tables I create. It is simple, easy to understand, and works! Now here is the domain model object that it maps to:

 


Notice that the domain object does not have a field called RoleId? Instead we have another field in our base called Id. Now seeing how AutoMapping requires convention (namely naming conventions) to map entities, how does Fluent NHibernate map this with AutoMapping? Well, unfortuntaly it can't:

 



However, with a little help from the Constraints API, we can easily resolve this mapping with a minimum amount of code. What are Conventions, you might ask? According to the Fluent Nhibernate documentation:

"Conventions are small self-contained chunks of behavior that are applied to the mappings Fluent NHibernate generates. These conventions are of varying degrees of granularity, and can be as simple or complex as you require. You should use conventions to avoid repetition in your mappings and to enforce a domain-wide standard consistency."

Connventions are a set of base classes and interfaces that when implemented, allow you to override the default AutoMapping behaviour. Pretty sweet. 

Ok, so how did I resolve the mapping exception above? First the Covention implementation:


And finally the configuration with Fluent NHibernate AutoMapping API:




Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

NHibernate | ORM

Decisions, Decisions, Decisions...NHibernate, Linq 2 Sql, or Entity Data Model 4.0?

by jmorris 11/12/2009 5:29:00 PM

I have a couple of projects coming up and I am trying to decide on a persistence framework to use. I pretty much narrowed the scope down to NHibernate and Fluent NHibernate, Linq2Sql, or Entity Framework 4.0 (there really on 4.0? really?). So far here is my 'superficial' thoughts, feelings about each (note that until I actually commit to one I won't truly understand it's benefits and/or limitations):

  1. NHibernate/Fluent Nhibernate
    1.  Yeas
      1. Cleanly separates persistence layer from domain layer - you can pretty much ignore the database
      2. Strong adoption amongst the 'in-crowd' - many, many Alt.Net and .NET bloggers/developers profess to it's prowess (Ayende, etc)
      3. Supposed strong community
      4. Very configurable - lots of OSS extensions, etc.
    2. Nays
      1. Lack of centralized ownership (IMO) - no single contributer/owner, lots of work outside the main trunk 
      2. Documentation is all over the place; some of it does not seem to be written clearly or lacks steps that require some amount of presupposed knowledge of NHibernate or one of it's dependencies
      3. No support from any of the larger software dev companies
      4. From the main source forge site I don't see much activity; i see more spam that has _not_ been removed than new members.
      5. First implementor syndrome?
  2. Linq2Sql
    1. Yeas
      1. Super simple, limited functionality ORM
      2. Used it, know it, no surprises
      3. Tons of documentation, blog entries, SEO fodder content...everyone has had a turn 
      4. Write code while others configure...
    2. Nays
      1. Obsolete - MS is moving to Entity Framework
      2. Minimalist ORM - you end up adding additional features (such as caching) - this could be a strong point as well
      3. Poor performance with many concurrent users until you optimize (which is relatively easy: compiled queries, etc)
  3. Entity Framework 4.0 
    1. Yeas
      1. Strong MS commitment (or so it seems, unless they have another MS Research project that cannibalizes on this one)
      2. Lots of current documentation
      3. Centralized community (well MS...)
      4. Seems like the have addressed the shortcomings of Entity Framework 3.0 - I won't really know until I commit to using it, the truth always comes out in the implementation
    2. Nays
      1. Previous versions of Entity Framework were horrible
      2. YAMSOSFAS - Yet another Microsoft one size fits all solution
      3. Trust - MS seems to jump from one thing to the next - outside the grokking of us mere mortals; what they support monday might be obsolete on tuesday.
      4. Personal - I always either build it myself or fall back to MS; I need some new experiances ;)
      5. I have worries about the how easy it is to break away from the MS model of horrible code generation experiences. I have seen enough MS brochureware to make me sick for life. I need real world flexibility with MY model, domain, etc. not what MS marketing deems significant.

So that is my initial, superficial perception of each persistence framework. Next up is looking into more specific and less subjective reasons for liking or disliking each ORM solution.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

ORM

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

Jeff Morris

Name of author Occasional rants about software development and software engineering in general.

E-mail me Send mail

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in