The Entity Framework is a data-oriented "solid frame" based on ADO. The following is referred to as EF.
It takes advantage of The abstraction of data structures, transforms each database object into an Application object (entity), and the data fields are converted to properties. The relationship is converted to a binding attribute (association), so that the E/R model of the database is completely transformed into an object model, so that programmers can invoke access in the most familiar programming language.
In my opinion, the classic explanation for EF is that the upper-level application code can access the data as an object-oriented approach.
In the past, we have directly read the database, the business data are using datasets, DataTable and so on to the value, resulting in ugly code, seriously divorced from the idea of OO.
For example, when storing to a database, the Entity Framework is primarily used to help us store objects in a database (that is, by "dealing with" objects with the database), as long as the object is given to the Entity Framework, without having to write the SQL statement itself, it will help us to generate SQL statements automatically. The SQL statements generated here are sent to the database via ADO, that is, the operation of the database or via ADO, so the first sentence of this article says "EF is a data-oriented ' Entity Framework ' based on ADO ."
The specific process can be expressed by:
For example, if you want to store two entities student and teacher in memory into a database, EF will automatically map the entity through the EDM, storing an entity as a record into the database, and how EF will determine which entity should be stored in which table, and which should be stored in which field? This is where the map is powerful:
In VisualStudio, the mapping is represented by an. edmx file , which is essentially an XML file that defines the conceptual model, the storage model, and the mappings between these models.
For example, in the mapping of the example above, it can be represented by a form similar to the following:
<!--CSDL represents the entity--><entity name= "Student" > <pro name= "Stuname" > <pro name= "Stusex" > <pro name= "stuage" ></Entity><!--SSDL here represents the database table--><table name= "Student" > <col Name= "Stuname" > <col name= "Stusex" > <col name= "stuage" ></Table><!--c-s This represents the mapping of entities to database tables--><relation entity= "Student" table= "Student" > <rel proname= "Stuname" Colname= " Stuname "> <!--entities in the Stuname attribute table in the Stuname field and <col proname=" Stusex "colname=" Stusex "> <col proname= "Stuage" colname= "Stuage" ></Relation>
The code above is not the exact format in the. edmx file, where the reader can be seen as a "pseudo code", followed by a brief description of the. edmx file creation and basic format.
As you can see from the perspective of Reading code, EF allows us to understand well without needing to understand data structures, and from an implementation point of view, EF can "model" storage as if many objects were stored in a list. Every instance is stored in the database table, and all of them are taken from the database. The program is so interactive with the database, and the OO code corresponds to each other, easy to "docking."
Entity Framework Learning Note--EF Introduction (an article tells you what EF is)