C#

Difference Between nHibernate and Entity Framework 4.0

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.

  1. 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
  2. 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
  3. nHibernate can be extended in terms of data loading, custom column types, custom collections, SQL generation, etc. Entity framework has restricted extension points.
  4. 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.
  5. 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.
  6. nHibernate provisions lazy loading for scalar properties like BLOB, CLOB. Entity framework does not supports lazy loading.
  7. nHibernate has support for extended cascading deletion of rows.
  8. nHibernate has more events included like preload, postload, updation, deletion.
  9. nHibernate has support for the 2nd level cache.

Summary

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.

Rajeev

Recent Posts

OWIN Authentication in .NET Core

OWIN (Open Web Interface for .NET) is an interface between web servers and web applications…

2 years ago

Serializing and Deserializing JSON using Jsonconvertor in C#

JSON (JavaScript Object Notation) is a commonly used data exchange format that facilitates data exchange…

2 years ago

What is CAP Theorem? | What is Brewer’s Theorem?

The CAP theorem is also known as Brewer's theorem. What is CAP Theorem? CAP theorem…

2 years ago

SOLID -Basic Software Design Principles

Some of the Key factors that need to consider while architecting or designing a software…

2 years ago

What is Interface Segregation Principle (ISP) in SOLID Design Principles?

The Interface Segregation Principle (ISP) is one of the SOLID principles of object-oriented design. The…

2 years ago

What is Single Responsibility Principle (SRP) in SOLID Design Priciples?

The Single Responsibility Principle (SRP), also known as the Singularity Principle, is a software design…

2 years ago