Home.NETEntity FrameworkWhat is Entity Framework?

What is Entity Framework?

What is Entity Framework?

Entity Framework is a set of technologies used for the development of data-oriented software applications. It is an Object-Relational Mapper (O/RM) that enables .NET developers to work with data using .NET objects. It helps in eliminating the need to write data-access code that developers normally write. The developers use the domain-specific objects and properties, such as employees and employee addresses, without having to concern themselves with the underlying database tables and columns where this data is stored.

Entity Framework helps the developers to work at a higher level of abstraction while dealing with data. They can create and maintain data-oriented applications with lesser amount of code than in traditional applications.

There are two major layers in an Entity Framework application:

  • The modeling layer
  • The object layer

The modeling layer contains three components:

  • A conceptual model consisting of domain-specific entity types and relationships, based on an Entity Data Model (EDM)
  • A database schema that defines tables and relationships
  • A mapping between the conceptual model and the database schema

Entity Framework uses the mapping component to transform operations against entity objectsā€”such as create, read, update, and deleteā€”into equivalent operations in the database.

The Entity Framework object layer contains typed common language runtime (CLR) objects that reflect the entities and relationships defined in the conceptual model. These objects can be consumed by programming languages. The exact format of the types is controlled by options you provide to Entity Framework.

Mapping and Modeling

There are different ways to create the mapping layer and the object layer:

  • You can use Entity Framework Tools to generate your model from an existing database. This generates a default conceptual model and mapping, which you can customize by using the Entity Data Model Designer. You can also use tools to graphically create a conceptual model by using the Entity Data Model Designer, and then generate a database based on the metadata built by the tool from that model.
  • You can use the Code First development to define your conceptual model in code. The Entity Framework infers the conceptual model based on the object types and additional configurations that you define. The mapping metadata is generated during run time based on a combination of how you defined your domain types and additional configuration information that you provide in code. The model can either be mapped to an existing database or you can generate a new database from your model.

Working with Objects

Entity Framework object layer enables you to do the following:

  • Run queries against the conceptual model.
  • Materialize data returned from the data source as objects.
  • Track changes that were made to the objects.
  • Propagate object changes back to the data source.
  • Bind objects to controls.
RELATED ARTICLES

2 COMMENTS

Comments are closed.

Most Popular