How Entity Framework Alternatives Evolved in ORM?

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

If you ask any .net developer, what is ORM tool? You will get instant reply Entity framework! But, still, people search for entity framework alternatives, Why?

Since I have also used entity framework in so many projects. I am just putting my points.

  • Performance is the main concern when using Entity Framework
  • SQL queries generated by EF are not much optimized
  • Not easy to update the database
  • Need to be careful when you are targetting production database

I am not sure about the latest version of Entity framework greater than 6. So please don’t make the wrong assumption about the latest version of EF.


Dapper was built by the StackExchange group. This ORM delivers amazing results since it leverages ADO.NET

To give you an idea of the performance, Matthew Jones from conducted a performance benchmark between Dapper, Entity Framework, and ADO.NET. His benchmark shows Dapper delivering exceptional performance over Entity Framework and narrowly edges out even ADO.NET.

While the performance is worthy, the technique of getting the data reminds me of the old days of retrieving data.

Here is a code example from their GitHub page:

public class Dog
     public int? Age { get; set; }
     public Guid Id { get; set; }
     public string Name { get; set; }
     public float? Weight { get; set; }
     public int IgnoredProperty { get { return 1; } }

var guid = Guid.NewGuid();
var dog = connection.Query("
                    select Age = @Age, Id = @Id", 
                          new { Age = (int?)null, Id = guid });
Assert.Equal(guid, dog.First().Id);

As you can see, it uses inline SQL to pull back the record and map it. The only thing missing is the left-to-right assignment.

Their GitHub page has a lot more examples of this and other entity framework alternatives.


nHibernate (introduced in 2007) is one of the oldest and most stable ORMs around and has been around longer than Entity Framework (introduced in 2008).

Most companies run their entire data access on nHibernate and are one of the most stable entity framework alternatives around.

I’ve heard tales of woe and tales of wonder with this product. It has a number of ways to configure your mappings whether it be in code or through XML.

While I’ve never worked with the product, it’s definitely vast in its configuration settings making it quite versatile.

Example Code:

//Add a Customer to the datastore

//'sessionFactory' is a thread-safe object 
  built once per application lifetime (can take seconds to build)

//based on configuration files which control 
       how database tables are mapped to C# objects

//(e.g. which property maps to which column in a database table)


//'session' is not thread safe and fast to obtain 
      and can be thought of as a connection to the database

using (var session = sessionFactory.OpenSession()) 
   //transaction represents a db transaction
   using (ITransaction transaction = session.BeginTransaction()) 

       //The line below adds the customer to NHibernate's list 
              of objects to insert to the database

       //but it doesn't execute SQL insert command at this stage*.

      //*if the Id field is generated by the database 
         (e.g. an auto-incremented number)

      //then NHibernate will execute SQL INSERT when .Save is called

      session.Save(new Customer 
                    Id = Guid.NewGuid(), 
                    FirstName = "Boss", 
                    Age = 50 

     //The call below will execute the 
          SQL INSERT and commit the transaction



//Retrieve the Customer from the database, modify 
       the record and update the database

using (var session = sessionFactory.OpenSession())
   using (ITransaction transaction = session.BeginTransaction()) 
       //session's Query returns IQueryable.
       //Only when .FirstOrDefault is called will NHibernate 
           execute the SQL query
       Customer customer = session.Query()
                                   .Where(c =>c.Token == token )
       //Now the customer is 'part of' the 'session' object 
            and NHibernate keeps track of changes
       //made to it
        if( customer != null ) 
           //Changing a property of an object does NOT cause SQL 
              to be executed
            customer.TokenVerified = true;
            //Committing the transaction results in an SQL UPDATE 
            //NHibernate kept track of the fact that 'customer' 
               has been changed since loading


Replacing the SQL statements with LINQ makes this example better in my opinion.

Why just two?

When examining the landscape of ORMs, I referred to a wiki page listing of object-relational mapping software for.NET.

Now, I don’t want to alarm anyone, but after looking through this list of ORMs, I realized that 75% of entity framework alternatives were names I’ve never heard of, don’t exist, or aren’t active.

I tried to remember some ORMs my colleagues used in the past. I remember the majority mentioning Entity Framework and NHibernate as their tool of choice with Dapper being the new guy on the block. In that order.

Even though Dapper is new, I couldn’t find any other mature, solid, stable, or popular ORMs



Do you think this was a useful article for you? Feel free to provide your comments and concerns in the below comment section.
[yikes-mailchimp form=”1″]

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on email
Author Bio

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recommended for you
Connect With Us
Stay Connected

Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.

Latest Articles

5 Best Apps for self-development

We live in a world of high dynamicity, progress, and constant change. But in most times it has been observed that we are not that welcoming when it comes to changing ourselves or changing anything around us. We try to repel change as long as possible.

Free hub for guest blogging nerds and newbie writers

  • Submit Guest Post
  • Share your Knowledge
  • Build your Backlinks
  • Advertise your products
  • Make money by writing
Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.