Blog

Filter posts by Category Or Tag of the Blog section!

Nhibernate vs Entity Framework

Monday, 15 October 2012

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

Category: Software

comments powered by Disqus