The majority of enterprise-level apps have a three-layered high-level application architecture:. The above diagram shows a simple NHibernate architecture as well as a high-level view of the NHibernate application. A simple NHibernate project, on the other hand, is made up of four key components as listed below -.
The following are some of the differences and advantages of utilizing NHibernate over Entity Framework. NHibernate is an open-source object-relational mapper for the. NET framework that is constantly evolving and feature-packed. Thousands of successful projects have employed it and have seen success over the years. We use cookies on our website for functional and analytical purpose and to enable sharing on social media.
By clicking "Agree", you agree with the placement and use of cookies by this website. What is NHibernate and how is it different from Entity Framework? Table of contents What is NHibernate? Simply put, NHibernate can be considered a database management system. Net framework based on the Object-Relational Mapping Technique. Architecture of NHibernate Many systems nowadays are developed with layered architecture; NHibernate is no exception and works flawlessly with it.
The majority of enterprise-level apps have a three-layered high-level application architecture: The Presentation layer The Business layer The Persistence layer The above diagram shows a simple NHibernate architecture as well as a high-level view of the NHibernate application. All database work is handled by NHibernate. Removes the need for SQL statements or the creation of a saved query. All the data access logic may be contained in the application. Still no support for grouping on the database side, it will be fixed in the next version.
No projections to non-entity types. It is also possible to do updates, deletes or inserts on top of LINQ queries, which is quite nice. Also, HQL is a great language for querying the database in an agnostic way; it is similar to SQL and can even update, insert or delete entries.
NHibernate can project to any class, not just anonymous types. NHibernate can use stored procedures or custom SQL for any kind of operation. EF Core still lacks this, which was present in pre-Core versions. NHibernate has futures, which means that multiple queries can be queued, executed on the database, and retrieved at the same time, for databases that support it SQL Server, Oracle.
Also, depending on the primary key generation strategy, one can also batch insert multiple records at the same time. Besides transactions, which are supported by all relational databases and major ORMs, some of these offer optimistic concurrency capabilities.
It can also compare all modified columns. EF Core still does not support ambient transactions TransactionScope , but the next version will fix that. NHibernate has historically had problems with TransactionScope , but they appear to be fixed now. Collections in EF Core are simple: just lists, which means, one-to-many. There is no support for many-to-many yet. Both one-to-many and many-to-many associations are supported. Current version of EF Core 2.
The next version 2. NHibernate can convert and query any type; EF Core still lacks this capacity, which should be introduced in the next version. With NHibernate, you can already query spatial types, for example.
Both of them have global filters at entity level. Easy to do soft deletes or multi-tenancy. Future versions will offer LINQ expression interception and lifetime events. NHibernate has a very rich event and interception model. Both offer first-level caching of entities. NHibernate goes one step further, and has second-level caching using a distributed cache provider, such as these:.
NHibernate can do validation using the companion project NHibernate Validator , or by implementing an interface this one has become somewhat legacy. EF Core uses Data Annotations validation , which is the de facto standard for doing validations in. This is one aspect where EF is quite ahead of NHibernate, even though there have been attempts to create a similar framework for it. You can list all the versions of a schema, apply one explicitly or go back to a previous version.
It should come with time, of course. EF can generate entities from the database, and you can even modify the default behavior by registering your own version of infrastructure services. NHibernate has so many features that it is easy to forget about one. With NHibernate, one can map pretty much any database, so there is always an option.
EF Core is very easy to use, generally well documented, and this is something where NHibernate is far behind. As of now, it can only be used in relatively simple scenarios — just consider the lack of support for table inheritance strategies. Having a. NET Core version is essential to me. Having the possibility of supporting non-relational databases using the same familiar APIs and concepts is something very appealing to me, but yet to see working.
EF Core does have a roadmap, which is a good thing. Learn more. What is NHibernate and why should I use it? Asked 11 years, 1 month ago. Active 11 years, 1 month ago. Viewed 31k times. Improve this question. Community Bot 1 1 1 silver badge. Maxim Zaslavsky Maxim Zaslavsky Oops, didn't realize that this is a dupe. Add a comment. Active Oldest Votes. Improve this answer. It would be interesting to know just how does the OP currently works with database.
There might be a change he hasn't done much even with ADO. NET, which would explain why he isn't crying his way out of it. The main purpose of NHibernate is described in the Wikipedia article as well: NHibernate's primary feature is mapping from. Dirk Vollmar Dirk Vollmar k 53 53 gold badges silver badges bronze badges.
0コメント