Object Relational Mapping

When developing a project, there are many ways to manage the project’s database connections and processes. However, many of these methods are new and slower than the old ones. Therefore, these methods should be learned well and the appropriate one should be used.

First of all, if newer ones are slower, why do we use them? Because they are more readable and away from clutter. Now let’s briefly look at new and old technologies and compare them.

Legacy technology : Ado.Net
New technology : ORM

Ado.Net, which stands for “ActiveX Data Objects.NET”, was made by Microsoft to act as a bridge between the applications and databases. Adding, deleting, updating and listing operations can be done in the database by writing SQL queries and commands to the application.

ORM is a technique that can access the database, make changes to the data and make queries using object-oriented programming languages. The ORM technique, which is a layer between the database and the project, actually serves the SOLID principles by separating the two jobs.

Another advantage of using the ORM technique is to make the database independent. Of course, this may vary depending on the ORM technique to be used, but you can easily switch between databases according to the ORM technique you will use.

Another important point for ORM technique is libraries. When using Ado.Net, the library is not used, but ORM techniques must be used with libraries. These libraries may vary depending on the language you use and the ORM technique.

There are many ORM techniques by language:

C#: Entity Framework, Dapper, ECO, XPO, Norm

Java: Hibernate, Ebean, Torque, JPA, MyBattis

Php: CakePHP, Codelgniter, RedBean, Doctrine, Propel, PdoMap

Python: Django, South, Stor

NodeJs : Sequelize

Now examine two of these techniques.

Actually, Dapper is not directly an ORM technique. Dapper is a micro ORM technique. This is because Dapper does not do any mapping or configuration settings in the background. For this reason, it has passed as a lightweight micro ORM technique. It was developed by the StackOverflow team and is published as open source on Github.

Entity Framework (EF) uses Ado.Net infrastructure. It contains the UnitOfWork design pattern. UnitOfWork ensures that these transactions are performed collectively through a single channel, instead of instantaneously reflecting every change made to the database.

With Entity Framework, you can develop projects using 4 different methods.
These methods are;
• Model First (Creating a New Database with Visual Studio)
• Database First (Using Existing Database)
• Code First (By Writing New Database Code)
• Code First(Using Existing Database

Famous image comparing ORMs and Ado.Net

First of all, when compared to the performance difference in this classic image, Dapper is much faster than Entity Framework. This speed is close to Ado.Net but should not be compared only in terms of performance.

From another point of view, code readability and developability. In this part, Entity Framework reveals the difference. Entity Framework, which completely abstracts us from SQL commands, closes the performance gap here.

Dapper Codes :

Entity Framework Codes :

These are the main differences between these two ORM methods, which can be compared in many ways. Performance and Readability.

Referances :

bolŞans…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store