nHibernate and ADO.Net Entity Framework are ORM frameworks (object relational mapping frameworks).This post lists the major difference between nHibernate and Entity Framework 4.0.
Entity framework is the Microsoft’s first ORM framework. Microsoft introduced ADO.NET Entity framework in .net framework 3.5 Service Pack 1.
In an object oriented language, object-relational mapping framework is used to map a database schema to corresponding domain objects.
These ORM frameworks are very helpful to map database data in your persistence layer of application code without the need of writing data access code.
nHibernate Vs Entity Framework
There are some variations in using nHibernate over Entity Framework. Also, there are some advantages of nHibernate as compared to entity framework as an ORM.
The listing below the advantages of nHibernate over entity framework.
- nHibernate works with pure POCO classes. But entity framework models are not pure POCO classes, they also comprise some lower level functionality along with business properties to work with database
- nHibernate supports all major types of databases but Entity Framework works perfectly with MSSQL and some need additional connectors to support other databases than MSSQL
- nHibernate can be extended in terms of data loading, custom column types, custom collections, SQL generation, etc. Entity framework has restricted extension points.
- Write batching – In nHibernate, we can be configure to batch all writes to the database so that when you need to write several statements to the database, nHibernate will only make a single round trip, instead of going to the database per each statement.
- Read batching (multi queries) – nHibernate allows to batch several queries into a single round trip to the database, but in entity framework there needs separate roundtrip per each query.
- nHibernate provisions lazy loading for scalar properties like BLOB, CLOB. Entity framework does not supports lazy loading.
- nHibernate has support for extended cascading deletion of rows.
- nHibernate has more events included like preload, postload, updation, deletion.
- nHibernate has support for the 2nd level cache.
Hope this list of difference between nHibernate and Entity Framework has helped you.We would like to know your valuable feedback. Please update if you like to share anything more on this topic nHibernate vs Entity Framework.