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:
Thank you, very good. point to point