Entity Framework Learning Series (1) - Recognition understand Entity Framework

EDITORIAL


When using .net mvc development. For efficient development, we often match ORM framework.

The Entity Framework is Microsoft developed an ORM framework. Under normal circumstances, we rarely use the full name,

But directly with EF. Because all Microsoft products, so it usually is and MVC gold partner.

What is the Entity Framework


The full name ADO.NET Entity Framework, referred to as EF. The advantage is capable of efficient development, the disadvantage is hurt performance.

So, if the business is too large, the performance requirements high. EF is not recommended for development.

You can use lightweight ORM framework for development.

EF advantages and disadvantages


1. Advantages

[1]. Greatly improve development efficiency. Write code very efficient, automated process.
[2]. Supports multiple databases (mysql, oracle, sqlserver).
[3] The strong mapping, visualization can support the operation.
[4]. Visual Studio provides integrated tools for visualization.

2. shortcomings

[1] .EF bad performance, performance loss. In complex queries, when the generated SQL script is not very efficient.
[2] The database end loss of performance is the same, but when converting the state of the object to SQL statements, will lose performance.

How to understand the ORM


  • Broadly, it is the conversion between the object model and object-oriented relational database data structures.

  • In a narrow sense, it is based on data stored in a relational database, data access interface a virtual object-oriented. OO in a persistent object does not need to know the implementation details of any relational database to store data.

  • There is no inheritance in a relational database in the world.

  • In object-oriented world, we use unidirectional association. However, geese, relational database in the world, we use a bidirectional association foreign key.

  • ORM is the object of the world and a bridge relations with the world, by mapping the relationship to simplify the amount of code the database.

The implementation of the principle of EF


EF执行的原理是 反射和特性

[1] First, to identify the characteristics of the EDM using a specific entity is mapped to the corresponding table TableName property of the ColumnName specific database, as well as the primary key, foreign key, default values, etc., it is identified characteristics.

[2] Then, for a description of the structure of the database table metadata from the database in EF edm by reflection technique

[3] According to another method CRUD operations, can be generated corresponding to the SQL statement.

[4] and then sends a ADO.NET,

[5] The final read data from the database by ADO.NET responsible, returned to EF.

Guess you like

Origin www.cnblogs.com/ZengJiaLin/p/11388094.html