Mapping |
It supports XML-based, Attribute-based and strongly-type code-based mappings |
It supports Attribute-based and strongly-type code mappings |
Database Support |
All type of DB Providers are supported E.g. Microsoft SQL Server (including Compact Edition), Oracle, Microsoft Access etc |
It supports SQL Server, SQL server compact edition provider, SQL Lite, SQL azure, oracle, MySQL |
Code First Mapping Support |
Yes |
Introduced from version 4.0 |
Lazy Loading Support |
Lazy loading for associated entities (one to one, many to one) Collections (one to many, many to many); Scalar properties (thing of BLOBs or CLOBs). |
Lazy loading for Associated entities Collections |
Migrations Support |
Supports only initial schema generation |
Built-in schema migration support Also supports seeding of the initial database |
Asynchronous call |
No |
Yes |
Connection resiliency |
Third party solutions exist with NHibernate.SqlAzure |
This feature was added to version 6; the connection resiliency feature automates the process of retrying failed SQL statements |
Code based Configuration |
NHibernate 3.2 with Fluent-NHibernate |
Available from version 4.1; Entity Framework automatically finds a class that derives from DbConfiguration; One can use the DbConfiguration class to complete configuration tasks in the source code. |
Querying API |
LINQ provider for NHibernate and Query Over–Similar to Criteria API, but uses strongly-typed LINQ expressions instead of strings. This is also the most commonly used today. |
Linq to Entities most used Entity-SQL-object oriented, database independent querying language Plain SQL |
Documentation |
Poor, but good forum support is available |
Good |
Cascading Support |
Yes |
Yes |
Caching |
Support second level caching |
Yes from version 6.0 |
Cascading Support |
Yes |
Yes |
Tracking changes |
Change tracking at the unit of work level |
Change tracking at the unit of work level Entity Framework also offers self-tracking entities. |
Events |
NHibernate has a very rich event model, that exposes more than 20 events, either for synchronous pre-execution or asynchronous post-execution, including Pre/Post-Load Pre/Post-Delete Pre/Post-Insert Pre/Post-Update Pre/Post-Flush |
Entity Framework only has two event-based extension points: ObjectMaterialized SavingChanges. |
Batching Support |
NHibernate has full support for insertion batching, but only if the ID generator in use is not database-based (for example, it cannot be used with Identity) |
No |
Flushing Changes |
NHibernate’s ISession has a FlushMode property that can have the following values: Auto Commit Never |
Entity Framework, changes have to be explicitly sent through a call to AcceptAllChages() SaveChanges() |
Custom type and collection support |
Yes |
No |
.NET 4.5 Support |
Yes |
Yes (with improved performance) |
Complexity |
Higher |
Easy |