Ehsan Ghanbari

Experience, DotNet, Solutions

Nhibernate vs Entity Framework

Entity framework and NHibernate are two famous ORM for developers. Both of them have been used in many projects and each of them has it's own cons and pros and common features as well. I'm gonna list some of them here. I personally like both of them and experienced in several projects. both Frameworks are used for processing relational data to domain-specific objects. Both NHibernate and the Entity Framework provide the capabilities required to implement an ORM using the Model First approach.

 

How do they work?

nHibernate: The ISessionFactory holds model and metadata that is tied to a particular database and to the settings that came from the Configuration object. Finally, you create instances of ISession from the ISessionFactory.

Entity Framework: the ObjectContext or DbContext holds the configuration, model and acts as the Unit of Work, holding references to all of the known entity instances. 

 

Migrations

Entity Framework: Built-in schema migration support since version 6 and supports seeding of the initial database

NHibernate: Supports only initial schema generation

 

Code First Mapping?

Both NHibernate and Entity Framework support the Code First Mapping feature.

 

Database Support?

NHibernate: SQL Server, SQL Server Compact, SQL Server Azure, Oracle, DB2, PostgreSQL, MySQL, Firebird, SQLite, Informix

Entity Framework: Entity framework only supports SQL Server (but by using some extensions you can use Oracle and MySQL too).

 

Caching?

Both of them support for the first level cache. NHibernate also supports for second level caching.

 

References:

I tried to list the features I've worked with and for the complete information you can see the following post:

https://weblogs.asp.net/ricardoperes/differences-between-nhibernate-and-entity-framework

About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns and I'm spending a lot of my time on architecture subject. Since 2008, I've been as a developer for companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the&nb Read More

Post Tags
Pending Blog Posts
Strategic design
Factory Pattern
time out pattern in ajax
Selectors in Jquery
Peridic pattern
How to query over Icollection<> of a type with linq
How to use PagedList In asp.net MVC
Using Generic type for type casting in F#
Domain driven design VS model driven architecture
What's the DDD-lite?
comments powered by Disqus