There are multiple blogs comparing EntityFramework (EF) vs NHibernate. NHibernate is an open source library while EF is Microsoft library. I have worked with both.
NHibernate has been in the community longer than EF. As of today, NHibernate offers more functionality than EF and the best ORM I have used. EF is easy to learn and for simple application, probably the right choice.
Few things where I felt constraint by EF
- No custom mapping conventions. Custom mapping conventions allow developer to define custom mappings between entity property to a column name, relationships and more.
- No cascade deletes for attached entities. Developer has to request a seperate call to delete orphan records.
- Mappings requires explicit property for foreign key in the entity. Example. Person entity has a Car entity. EF requires CarID property in Person for mapping purpose.
- Even though EF claim to support TPH mapping, it does not work when outside entity is added to the relationship. TPH works by itself for the class heirarchy but when another entity reference to the TPH entity. The relationship fails to map correctly. You do have a workaround by adding extra column per each entity to establish new foreign key properties.
- EF lacks extensibility which NHibernate offers including caching, query interceptions etc.
- Limited support for store procedures.
- Domain Driven Design is harder to implement with EF due to lack of features.
The only drawback for NHibernate is the lack of documentation. It might be a stiff learning curve. Since the community is larger, there are plenty of blogs and forums to support your queries.
Most organizations don’t use NHibernate just because it is an open source library not supported by a large organization. As a developer, I would learn both ORMs.