我們來看看EF的框架設計吧:
The following figure shows the overall architecture of the Entity Framework. Let us now look at the components of the architecture individually:
EDM (Entity Data Model): EDM consists of three main parts - Conceptual model, Mapping and Storage model.
Conceptual Model: The conceptual model contains the model classes and their relationships. This will be independent from your database table design.
Storage Model: Storage model is the database design model which includes tables, views, stored procedures, and their relationships and keys.
Mapping: Mapping consists of information about how the conceptual model is mapped to the storage model.
LINQ to Entities: LINQ to Entities is a query language used to write queries against the object model. It returns entities, which are defined in the conceptual model. You can use your LINQ skills here.
Entity SQL: Entity SQL is another query language just like LINQ to Entities. However, it is a little more difficult than L2E and the developer will have to learn it separately.
Object Service:Object service is a main entry point for accessing data from the database and to return it back. Object service is responsible for materialization, which is the process of converting data returned from an entity client data provider (next layer) to an entity object structure.
Entity Client Data Provider:The main responsibility of this layer is to convert L2E or Entity SQL queries into a SQL query which is understood by the underlying database. It communicates with the ADO.Net data provider which in turn sends or retrieves data from the database.
ADO.Net Data Provider:This layer communicates with the database using standard ADO.Net.
EDM(Entity Data Model)【實體數據模型】:實體數據模型包含三個主要部分:概念模型,映射,存儲模型;
Conceptual Model【概念模型】:包含模型類和類之間的關系。概念模型是獨立于數據庫設計的;
Storage Model【存儲模型】:存儲模型是數據庫設計的實體,它包含數據表,視圖,存儲過程,還有他們之間的關系和鍵值;
Mapping【映射】:映射包含這個概念模型怎么映射到存儲模型的信息;
LINQ to Entities:LINQ to Entities是查詢語言,用來查詢對象模型。它返回的是定義在概念模型中的實體;
Entity SQL:Entity SQL是另外的查詢語言,就像LINQ to Entities一樣,然而它和LINQ to Entities有一點不同,我們需要單獨去學一下;
Object Service:Object Service是一個主要的切入點去從數據庫中獲取數據,并返回數據。Object Service負責將數據返回給Entity Client Data Provider實體對象結構;
Entity Client Data Provider:它主要的職責是將L2E(LINQ to Entity)或者Entity SQL查詢語言,拼接成底層數據庫可以理解的語言。它負責和ADO.NET Data Provider通信;
ADO.NET Data Provider:這個層,主要是用標準的ADO.NET和數據庫打交道。
好了,EF的框架,差不多學到這里,相信大家已經有了一個基本的理解了。
文章列表