NHibernate Vs Entity Framework 6.0 – A Comparison

Here is a nice comparison table for NHibernate and Entity framework 6.0. This is the result of my searching and reading, to get to know over the evolution of Entity Framework (the latest is V6.0). Enjoy reading!

Feature

NHibernate

EF 1.0 to EF 6.0

Current version

V3.3.3

V 6.0

Year released

 Hibernate (JAVA) 2001/ NHibernate (.NET) 2005

2008

Introduced

.NET 1.1 and above/Mono

.NET Framework 3.5 SP1 and above

Open source

Yes

Yes from 6.0

Associations

Both supports 1 to 1, 1 to many, and many to many

Both supports  1 to 1, 1 to many, and many to many

Rich domain models

Yes

No

Ordered and unordered sets collection. Indexed options. It even has an immutable, indexed list

Yes

No

Mapping private fields (yet) or can you directly use a dictionary class

Yes

No

Collection supports

IDictionary<T,T>  IEnumerable<T>

ICollections

Supporting ENUM

Yes

Yes from 6.0

Vendor support /Providers:

SQL Server/Azure, SQLite, PostgreSQL, Oracle, Sybase, Firebird and DB2

All the DB providers are built-in

SQL Server or SQL Azure,

Code first

Yes

From EF 5.0

Code-based mapping

NHinernate 3.2 with Fluent-NHibernate

From EF 6.0

Supporting custom types and collections

Yes

No

Query flexibility

HQL/QueryOver/Criteria API/Native Vendor specific SQL (3.2 with the above & lot more)

LINQ/Entity SQL/Native SQL/Commercial  provider for ORACLE

Extensibility

Uses Listeners/Configuration properties

ServiceLocator pattern

Async/await support

No

EF 6

Built-in support for automatically reconnecting to the database

No

Yes

.NET 4.5 support

Yes

Yes (with improved performance)

Batch processing

With “Future”

No

Creating a DBContext with an existing open connection

No

Yes

Spatial support

Need 3rd party

In-built

Documentation

Poor, but can get lot of support over forum

Good

Caching

Support second-level caching

Yes from EF6

Events

“NHibernate has a very rich event model, that exposes more than 20 events, either for synchronous pre-execution or asynchronous post-execution”.

Entity Framework only has two event-based extension points: ObjectMaterialized and SavingChanges

Tracking Changes

No

While both default to change tracking at the unit of work level, Entity Framework also offers self-tracking entities.

Able to map SQL views

Yes

No

Querying SSAS OLAP cubes

No

Yes

Interception of queries/object creation

Yes

No

API Methods

Save, Update, SaveOrUpdate, SaveOrUpdateCopy, Replicate and Merge,

 

Lazy loading behavior

One an relationship by relationship basis

For the entire context

Courtesy:

http://dotnet.dzone.com/articles/entity-framework-56-vs

http://weblogs.asp.net/ricardoperes/archive/2012/06/07/differences-between-nhibernate-and-entity-framework.aspx

Advertisements

1 Comment »

  1. 1

    Thank you, very good. point to point


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: