ADO. NET Entity Framework

Source: Internet
Author: User

ADO. NET Entity Framework is Microsoft with ADO. the object relationship correspondence (O/R Mapping) solution developed Based on. NET, known as objectspace, is now included in Visual Studio 2008 Service Pack 1 and.. NET Framework 3.5 Service Pack 1.

Directory

Introduction
Entity Framework Version Information
Background
Architecture
Client Support
Development Tools
Derivative Service
Support vendor
Expand
Introduction
Entity Framework Version Information
Background
Architecture
Client Support
Development Tools
Derivative Service
Support vendor
Expand
Introduction ADO. NET Entity Framework is mainly composed of Entity Data Model (EDM). The data logic layer is divided into three layers: Conceptual schema, mapping schema, and storage schema. entity client, object context and LINQ can be used. Entity Framework Version Information ADO. NET Entity Framework has been integrated into. Net since. Net 3.5. The latest version is Entity Framework 5.0.
Version Support for. net Release status Remarks
Entity Framework 3.5 2.0 + Included in. Net 3.5 Supports edmx generation and poco class generation through extension
Entity Framework 4.0 4.0 + Included in. Net 4.0  
Entity Framework 4.x 4.0 + Available through nuget Supports three generation modes: database first, model first, and code first.
Entity Framework 4.5 4.5 + Integrated In. Net 4.5  
Entity Framework 5.x 4.5 + Available through nuget Supports enumeration fields, greatly improving performance. the. NET 4.0 version is Entity Framework 4.4.
Background For a long time, programmers and databases have always maintained a subtle relationship. In commercial applications, databases must be an indispensable component, which makes Program Designers must connect to and access the database

ADO. NET Entity Framework Architecture

Learning SQL commands, many people in the information industry are studying how to integrate program design models with databases. The technology of object-relational ing is born from this, hibernate or nhib.pdf are the products of this technology, while Microsoft has ADO. net is a powerful tool for data access, but there is no tool for objects such as nhib.pdf. in the development period of Net Framework 2.0, an objectspace concept was proposed. objectspace allows applications to connect to and access the database in a completely object-oriented way. The technical concept of objectspace is similar to that of nhib.pdf, however, the objectspace project is quite large. net Framework 2.0 is still not complete, so Microsoft will include objectspace in the next version. net Framework, and add a design tool (designer), constitute the current ado . NET Entity Framework. The Entity Framework converts each database object to an application object (entity) using the abstract data structure, and converts data fields to properties ), the relationship is converted to association, so that the E/R Model of the database is fully converted into an object model, so that the programmer can use the most familiar Programming Language . Under the abstract structure, it is the concept layer, corresponding layer and storage layer of highly integrated and corresponding structure, and the data provider (provider) that supports Entity Framework ), this enables smooth and complete data access. (1) concept layer: exposes and accesses objects and attributes in the upward direction. (2) Corresponding layer: maps the concept layer above and the data structure of the bottom storage layer. (3) storage layer: displays the data structure of an object based on different databases and data structures. Together with the provider, the storage layer is responsible for actual database access and SQL generation. Architecture Concept Layer Structure The concept layer structure defines the object model so that upper-layer application codes can access data in an object-oriented manner. The concept layer structure is defined by CSDL (Conceptual schema definition language) write 1. The definition of a conceptual layer structure is as follows: <? XML version = "1.0" encoding = "UTF-8"?> <Schema namespace = "employees" alias = "self" xmlns = "http://schemas.microsoft.com/ado/2006/04/edm"> <entitycontainer name = "employeescontext"> <entityset name = "employees" entitytype = "employees. employees "/> </entitycontainer> <entitytype name =" employees "> <key> <propertyref name =" employeeid "/> </key> <property name =" employeeid "Type = "guid" nullable = "false"/> <property name = "lastname" type = "string" nullable = "false"/> <property name = "firstname" type =" string "nullable =" false "/> <property name =" email "type =" string "nullable =" false "/> </entitytype> </Schema> Corresponding Layer Structure The corresponding layer structure combines the upper-layer conceptual Layer Structure and members in the lower-layer storage structure to confirm the data source and flow. The corresponding layer structure is written by MSL (mapping specification language) 2. The structure of a corresponding layer is defined as follows: <? XML version = "1.0" encoding = "UTF-8"?> <Mapping Space = "C-S" xmlns = "urn: Schemas-Microsoft-com: Windows: Storage: mapping: CS "> <storageentitycontainer =" DBO "cdmentitycontainer =" employeescontext "> <entitysetmapping name =" employees "storeentityset =" employees "typename =" employees. employees "> <scalarproperty name =" employeeid "columnname =" employeeid "/> <scalarproperty name =" lastname "columnname =" lastname "/> <scalarproperty name =" firstname "columnname = "firstname"/> <scalarproperty name = "email" columnname = "email"/> </entitysetmapping> </entitycontainermapping> </mapping> Storage layer structure The storage layer structure is responsible for ing entities with data tables in the database management system (DBMS) so that data can be entered into the correct data source or retrieved from the correct data source. It is written by SSDL (storage Schema Definition Language) 3. The storage layer structure is defined as follows :? XML version = "1.0" encoding = "UTF-8"?> <Schema namespace = "employees. store "alias =" self "provider =" system. data. sqlclient "providermanifesttoken =" 2005 "xmlns =" http://schemas.microsoft.com/ado/2006/04/edm/ssdl "> <entitycontainer name =" DBO "> <entityset name =" employees "entitytype =" employees. store. employees "/> </entitycontainer> <entitytype name =" employees "> <key> <propertyref name =" employeeid "/> </key> <property name =" employeeid "Type = "uniqueidentifier" nullable = "false"/> <property name = "lastname" type = "nvarchar" nullable = "false" maxlength = "50"/> <property name =" firstname "type =" nvarchar "nullable =" false "/> <property name =" email "type =" nvarchar "nullable =" false "/> </entitytype> </Schema> Client Support After defining the CS/MS/SS of the Entity Data Model, you can use ADO.. NET Entity Framework client to access EDM. The data provider in EDM accesses data from the data source and then returns the data to the client. Currently, the ADO. NET Entity Framework has three clients: Entity Client The entity client is ADO. native client in NET Entity Framework, its object model and ADO. other clients of net are very similar. They have objects such as connection, command, and datareader, but the biggest difference is that they have their own SQL commands (Entity SQL ), you can use SQL to access EDM. Simply put, EDM is treated as an entity database. // Initialize the entityconnectionstringbuilder. entityconnectionstringbuilder entitybuilder = new entityconnectionstringbuilder (); // set the provider name. entitybuilder. provider = providername; // set the provider-specific connection string. entitybuilder. providerconnectionstring = providerstring; // set the metadata location. entitybuilder. metadata = @ "res: // */adventureworksmodel. CSDL | res: // */adventureworksmodel. SSDL | res: // */adventureworksmodel. MSL "; console. writeline (entitybuilder. tostring (); Using (entityconnection conn = new entityconnection (entitybuilder. tostring () {Conn. open (); console. writeline ("just testing the connection. "); Conn. close ();} Object context Because entity client is too standard and not in line with the ORM spirit, Microsoft adds an interface at the top of entity client for direct access by programming languages, EDM can be accessed as an object. This interface is called object context (Object Service ). Any actions on EDM in the object context will be automatically converted to Entity SQL and sent to EDM for execution. // Get the contacts with the specified name. objectquery <contact> contactquery = context. contact. where ("it. lastname = @ ln and it. firstname = @ FN ", new objectparameter (" ln ", lastname), new objectparameter (" FN ", firstname )); LINQ to entities The object context changes EDM access to an access method for the object set, which makes it possible for LINQ to take full advantage of it. Therefore, the connection between the object context and the object context is generated. In short, it is to use LINQ to access EDM, so that the functions of LINQ can be used in the database. Using (adventureworksentities awentities = new adventureworksentities () {objectquery <product> Products = awentities. product; iqueryable <product> productnames = from P in productsselect P; Development Tools Currently, ADO. NET Entity Framework Development, which is fully supported in Visual Studio 2008. After Visual Studio 2008 Service Pack 1 is installed, ADO will appear in the file template. net object data model (ADO. NET Entity Data Model) allows developers to use entity model designer to design EDM. EDM can also be edited by notepad or text editor. Derivative Service Primary entry: Ado. NET data services

Ado. NET Entity Model Designer

Microsoft develops an ado-based solution for various applications on the network, such as Ajax, Silverlight, and mashup applications. the service on the Net Entity Framework is called ADO. NET data services (project code: Astoria), and.. NET Entity Framework packaged together in.. NET Framework 3.5 Service Pack 1. support vendors currently, several database vendors or component developers have announced their support for ADO. NET Entity Framework: (1) core lab, which supports Oracle, MySQL, PostgreSQL, and SQLite databases. (2) IBM implements the LINQ provider used by DB2. (3) MySQL, the provider used to develop MySQL server. (4) npqsql: The provider used to develop PostgreSQL. (5) openlink software, which is developed to support providers for multiple databases. (6) Phoenix Software International, developing a provider that supports SQLite databases. (7) Sybase, which supports the Anywhere Database. (8) vistadb software, which supports the vistadb database. (9) DataDirect Technologies has developed providers that support multiple databases. (10) Firebird: supports Firebird databases.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.