Results 1 to 8 of 8

Thread: EF or NHirbernate?

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    EF or NHirbernate?

    I started to learn EF, is Nhirbernate better alternative as O/RM? please do advice. thanks

    If a post has helped you then Please Rate it!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: EF or NHirbernate?

    I haven't used NHibernate a lot so I don't know everything about it but I will give my impressions. The original version of EF was limited and did create numerous issues when used in any but the simplest situations. In those days, the power and stability of NHibernate made it easily the better choice for enterprise development. EF has come a long way in a short time though, and the current version is significantly more functional than the original. With it's increased functionality and VS integration, it seems to me that EF is the better choice these days. I'm sure that the fluent interface is much nicer but I was using XML configuration files when I used NHibernate and I found that rather laborious. NHibernate, in my experience, is more manual and therefore might appeal to those who like having that level of control but, when that level of control is not actually required, you can be more productive with EF.

  3. #3
    Addicted Member
    Join Date
    Oct 2008
    Location
    India, Kerala, Calicut
    Posts
    242

    Re: EF or NHirbernate?

    When it come to ORM it good to use nHibernate as it connect the database and the classes withour writing any additional codes

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: EF or NHirbernate?

    Quote Originally Posted by sanju4kk View Post
    When it come to ORM it good to use nHibernate as it connect the database and the classes withour writing any additional codes
    You do know that that's what EF does too, right? In fact, that's basically what all ORMs do because that's exactly what an ORM is for. From that point of view, EF is better because it can be less work because it will generate the entity classes from the database or the database from the entity classes. What you've mentioned is just an advantage of using an ORM, not an advantage of using NHibernate over any other ORM.

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Re: EF or NHirbernate?

    My personal view on EF is that if my application has many concurrent users, I would never ever use EF. It's the slowest framework there is. Although MS has optimized it a bit in 4.5, its still slow as hell. In my applications I use micro-ORM like Dapper or PetaPoco, They run 4-5 times faster than EF. The only downside is that micro ORMs can't really have complex object relations. But I would gladly sacrifice "ease of use and object navigation" to speed.

    http://www.toptensoftware.com/Articl...oco-More-Speed

    And the beauty of miro ORM is that you still get to use LINQ. PetaPoco also has a built-in server side paging support. Here is a little example:
    Code:
    //EF
    var myrecs = dbContext.MyTable.Where(a=>a.MyField == MyValue).Skip(20).Take(20);
    
    //PetaPoco
    var myrecs = db.Page<MyTableType>(currentPageIndex, PageSize, "select * from MyTable where MyField == @0", MyValue);
    Last edited by Serge; May 10th, 2013 at 07:24 PM.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: EF or NHirbernate?

    Quote Originally Posted by Serge View Post
    My personal view on EF is that if my application has many concurrent users, I would never ever use EF. It's the slowest framework there is. Although MS has optimized it a bit in 4.5, its still slow as hell. In my applications I use micro-ORM like Dapper or PetaPoco, They run 4-5 times faster than EF. The only downside is that micro ORMs can't really have complex object relations. But I would gladly sacrifice "ease of use and object navigation" to speed.
    I'm not arguing with you as I'm sure the options that you suggested were built for speed but, while I have no figures to back it up, I will say that EF using POCOs is almost certainly significantly faster than the original code-heavy entities.

  7. #7
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: EF or NHirbernate?

    Don't forget you may have the option of using a non-relational store such as RavenDB that obviates the need for an ORM layer entirely.

    http://jeremydmiller.com/2013/05/13/...ravendb-again/
    RavenDb has to be the easiest persistence strategy in all of software development to get up and running on day one. Granted that you’ll have to change settings for production later, but you can spin up a new project using RavenDb as an embedded database and start writing an application with persistence in nothing flat. I’ve told some of my ex-.Net/now Rails friends that I think I can spin up a FubuMVC app that uses RavenDb for persistence faster than they can with Rails and ActiveRecord. The combination of a document database and static typed document classes is dramatically lower friction in my opinion than using static typed domain entities with NHibernate or EF as well.
    (emphasis mine)

  8. #8
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Re: EF or NHirbernate?

    If you need a Document database (NoSQL), I would chose MongoDB over RavenDB, besides MongoDB is free.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width