Entity Framework is one of the most popular ORM framework on
the .NET world, it enables to work with relational data using domain-specific
objects and eliminates the need for most of the data-access code. EF 1 came out
with .NET 3.5, EF 5 released targeting .NET Framework 4.5 and is now on EF 6
alpha3. For 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.
Below are few of the Entity Framework benefits and liabilities compare to NHibernate:
Benefits:
Additional links to refer:
Below are few of the Entity Framework benefits and liabilities compare to NHibernate:
Benefits:
- Entity Framework and NHibernate both default to change tracking at the unit of work level, also offers self-tracking entities.
- Entity Framework of has close integration ties with Visual Studio and various ASP.NET and WCF libraries.
- Entity Framework has a great LINQ support
- Entity Framework is superior on documentation
and NHibernate lacks and need to synchronize with an up to date API reference with
its current version.
Liabilities:
- Entity Framework follows a more traditional .NET design where everything is encapsulated in a single ObjectContext or DbContext. This makes using the object far more straight forward, but the downside is that the class is therefore not lightweight compare to NHibernate
- Entity Framework does not have any built-in support for second-level caching, but there are samples for adding second-level caching.
- Entity Framework only has two event-based extension points: ObjectMaterialized and SavingChanges. NHibernate has a very rich event model.
- EF and NHibernate supports cascading for collections and associations: when an entity is deleted, their conceptual children are also deleted. NHibernate also offers the possibility to set the foreign key column on children to NULL instead of removing them.
- EF is yet to provide 100% support for batching.
- Out of the box, Entity Framework only supports
SQL Server, but providers exist to support other databases both free and
commercial.