Entity framework orm object relational mapper

Entity Framework is a Object Relational Mapper data API that enables programmers to query and update data stored in a database in a oops way. Oops way means, using entity framework, we can map database tables to .net classes. By mapping, we can set relationships between databases and the classes. By doing so, we can avoid writing SQL statements, as the framework will generate the appropriate sql execution logic.

ORMs are a solution to complex enterprise level ERP application programming. ORMS are designed as a solution to build an interface between the relational databases model and object oriented models to solve the problem of impedance mismatch.

What is impedance mismatch?
In the relational model, data is stored in a table and relationships are set among the tables and this data is in the normalized form to optimize the performance. To implement the business processes in the ERP application, application developers define the business processes in terms of classes, objects and inheritance hierarchy. This creates a mismatch.

Impedance mismatch refers to the inefficient transfer and usage of resources due to the difference in the way the database and the applications work. Programmers write code to bridge the gap between the OOPS model and relational model and this is additional work which can be avoided.

A good example of impedance mismatch is, data is handled in the object-oriented model as classes and objects, which are stored as rows and columns in a table in the relational database.

The ADO.NET Entity Framework addresses the above problem.

Roles of ORMS
ORMs maintain a unit of work pattern. A Unit of Work keeps track of everything that happens to a database during a business transaction. Using ORMs, we can maintain a list of business objects and also keep track of changes done to the object during updating, editing and adding. Examples of a Unit of Work are DataContext class in LINQ to SQL and the ObjectContext class in the Entity Framework. The DataSet can also be used as a Unit of Work.

ORMs provide an Identity map which keep track of all objects that have been read from the database in a single business transaction.

Lazy loading is a resource optimizing feature of ORM and is ref erred to the feature of loading a resource only when needed.

ORMs facilitates us to write object oriented queries which are translated to SQL statements which a database can understand. For example, if you are using an oracle database, ORMs convert object oriented queries to Oracle specific sql dialect. An ORM will cache data if it is not changed and make it available when required. This increases the performance of the application.

ORMs hide the underlying database and this allows us to scale the database application which is a common scenario when enterprise applications are installed and used in companies.

There are three ORMS used by enterprise ERP software developers. They are : LinqToSQL, EntityFramework and nHibernate(open source)