Performance analyze ADO.NET and Entity Framework

  1. First time EF loads metadata into memory, that takes a time. It builds in-memory representation of model from edmx file, or from source code if you are using code first. Actually EF is build at the top of ADO.NET, so it can't be faster. But it makes development much faster. And improves maintainability of your code.
  2. See 1

Take a look on msdn article Performance Considerations (Entity Framework)


  • 1) EF makes a lot of things more comfortable when working with databases. There is a lot going on under the hood that you otherwise would have to code manually.

For example, one of my first bigger projects was dealing a lot with data and I implemented the access layer with ADO.NET. This made up for something between a quarter or even a third of the whole project.

With my experience of the EF today I could get rid of nearly all of that! I just makes lots of the complicated code I wrote by hand completely unneccessary. We are talking about thousands of lines here.

  • 2) Two main reasons here. First, EF is built on top of using ADO.NET. This means that everthing EF does, add more overhead to whatever ADO would do. Second (very) simply put, the JIT compiler compiles the code for the first time just when it is executed. This includes memory allocation and all sorts of initializations.

This means that code you run multiple times runs much faster from the second time on. If you execute your EF queries only once, on the other hand, you will have no gains from those initializations.

In a real world application you might try to do some optimizations like using Compiled Queries. Performance wise this will help you a lot because now your queries do not need to be prepared and compiled each time you run them but only once.