Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving from Entity Framework to NHibernate

Currently we have 2 databases that we are going to use. One comes from a pre-existing product and thus we have no control over it. the other is one that we have full control over.

Currently we use the EF4 CTP as we need spatial features but obviously this cannot be used in product code and the recent release of EF hasn't spatial as this is for a later release of the .Net Framework and so the decision is being made as to the way forward and one suggestion is to move to NHibernate and use the spatial addon.

So first question is regarding the learning curve and move between the tools. To my eyes it seems NHibernate is more visible on what it is doing, EF hides a lot of what it does in typical MS style, would that be fair?

So I am thinking the way forward is to use a class diagram to describe the database that we have control of. We then would create the POCO lasses from that and then you need to create mapping files. Is it really as straight-forward as that? These mapping files, do we need to manually write them or do we have a tool to create from the POCO classes?

The next question is regarding the pre-existing database and what we do here. EF makes it easy to import the database and create the classes and is it as straight-forward in NHibernate?

In case it affects the answers

The database we have control of uses a MS SQL database. The one we don't is Oracle and we use the ODAC Entity Framework code from Oracle.

Thank you very much

like image 596
Firedragon Avatar asked Jan 17 '12 09:01

Firedragon


People also ask

Is NHibernate better than Entity Framework?

EF Core can use a ROWVERSION/TIMESTAMP column on SQL Server, or any of a list of columns, when updating a record. NHibernate offers richer capabilities, besides SQL Server ROWVERSION/TIMESTAMP, it can also use database native mechanisms such as Oracle's ORA_ROWSCN, but also timestamp or version columns.

Is Dapper faster than NHibernate?

Micro ORM performance comparing to different types of ORM As you see the fastest is Dapper, which provides similar results as the SqlDataReader class. When comparing full-featured ORM tools the fastest is NHibernate, but still, it's 2 times slow than Dapper.

Is NHibernate a framework?

NHibernate is an object–relational mapping (ORM) solution for the Microsoft .NET platform. It provides a framework for mapping an object-oriented domain model to a traditional relational database.


1 Answers

For an existing database, I recommend using Fluent NHibernate for the mapping. There is a good example of this in the Sharp Architecture project

There are tools that do both POCO generation and Fluent Mapping, I haven't tried any of them but I have read about them.

like image 93
Anders Forsgren Avatar answered Oct 03 '22 06:10

Anders Forsgren