cool hit counter EntityFramework Learning Notes - Introduction to EF (an article that tells you what EF is)_Intefrankly

EntityFramework Learning Notes - Introduction to EF (an article that tells you what EF is)

Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission.

Entity Framework is based on ADO.NET, data-oriented "entity framework". Hereafter referred to as EF.

It uses the abstraction of data structures, converting each database object into an entity, data fields into properties, and relationships into associations, so that the database E/R model is completely transformed into an object model, allowing programmers to call and access it in the most familiar programming language.

Personally, I think one of the more classic explanations of EF from wikipedia is that it allows the upper application code to access data as if it were object-oriented.

In the past, we have read the database directly, and business data are used DataSet, DataTable, etc. to pass values, resulting in ugly code and a serious departure from the OO idea.

For example, when storing to the database, the entity framework is mainly used to help us store an object to the database (that is, through the object and the database "deal"), as long as the object to the entity framework, do not have to write their own SQL statements, it will help us automatically generate SQL statements, where the generated SQL statements sent to the database through ADO.NET, that is, to operate the database or through ADO.NET, so the first sentence of this article said "EF is Based on ADO.NET , a data-oriented 'entity framework'."

The exact process can be represented in the following diagram.

As shown above, if you want to store two entities in memory, Student and Teacher, into the database, EF will automatically pass the entities through theEDM The mapping that stores an entity as a record into the database, so how does EF determine which entity should be stored in which table and which attribute should be stored in which field? This is where the power of mapping comes in.

In VisualStudio, the mapping is done through the .edmx file to represent, the .edmx file is essentially an XML file that defines the conceptual model, the storage model, and the mapping between these models.

For example, in the mapping in the above example, this could be represented by a form similar to the following.

<!-- CSDL This denotes the entity -->
<Entity Name="Student">
    <Pro Name="StuName">
    <Pro Name="StuSex">
    <Pro Name="StuAge">

<!-- SSDL  This indicates the database table -->
<Table Name="Student">
    <Col Name="StuName">
    <Col Name="StuSex">
    <Col Name="StuAge">

<!-- C-S  This indicates the mapping relationship between the entity and the database table -->
<Relation Entity="Student" Table="Student">
    <Rel ProName="StuName" ColName="StuName">  <!-- in the real worldStuName Attribute Correspondence TableStuName (numeric, data) field-->
    <Col ProName="StuSex" ColName="StuSex">    
    <Col ProName="StuAge" ColName="StuAge">

The above code is not .edmx The exact format in the document, Here, for the sake of simple illustration, The reader can look at it as“ pseudocode”, This will be briefly described later.edmx Document creation and basic format。

As you can see from the above, from a code reading point of view, EF allows us to understand the data structure without having to understand it; from an implementation point of view, EF can "model" the storage as if many objects were stored in a list, storing one instance to the database table and fetching one instance from the database. The program interacts with the database in such a way that it corresponds to the OO code and is easily "interfaced".

1、What kind of cryptocurrency battle will be presented at the end as Rilancoin leads the pace of the new cryptocurrency
2、Four Blockchain Myths
4、Global Interbank Financial Telecommunications Association Releases Blockchain Concept Certification Results banks can use distributed ledgers for realtime transactions
5、Repayment software vs online loans which is more reliable

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送