Example wizard for getting started with ADO. NET Entity Framework (with demo program download) Example wizard for getting started with ADO. NET Entity Framework (with demo program download)

Source: Internet
Author: User
Example wizard for getting started with ADO. NET Entity Framework (with demo program download) ADO. NET Entity Framework Getting started example wizard (with demo ProgramDownload) ADO. NET Entity Framework is an entity framework introduced by. NET Framework 3.5 SP1. It allows developers to focus on data through the Object Model (rather than the logical/Relational Data Model. The Entity Framework uses the concept layer, ing layer, and logic layer to abstract the logical database structure. This article Http://forum.entlib.com Open Source Forum team. Entity Data Model ( Entity Data Model ) The core of an Entity Framework lies in its model. The Entity Framework supports logical storage models that represent relational architectures in databases. Relational databases usually store data in different ways than applications use data. Generally, this forces developers to retrieve data based on the structure of the database containing data. Therefore, developers usually load data into business entities that are more suitable for processing business rules. In this example, the relational database architecture is represented by a logical model, and the business entity represents the conceptual model. The Entity Framework uses the ing layer to build bridges between models. Therefore, the Entity Framework Model has three active layers: 1. Concept layer ( Conceptual Layer ) - Indicates the conceptual model of data, including entities and relationships. 2. Logic layer ( Logical layer ) - Describes the storage model of data in the database. 3. Ing layer ( Mapping Layer ) - Establishes a ing between the concept layer and the logic layer model. These three layers allow you to map data from a relational database to a more object-oriented business model. The Entity Framework provides XML File defines the methods of these layers. It also generates a series of classes based on the conceptual model architecture. You can program these classes to directly interact with data. This provides an abstraction level, so developers can program conceptual models rather than relational models. The following shows how to use entity framework to build an example program. First, use Entity Data Model Wizard Create the following northwinddb. edml file.

Conceptual Model and Logical Model View:

This example uses the northwind sample database. Code Add, delete, modify, and query the MERs table. 1. Add MERs Record Using(NorthwindentitiesMydb =New Northwindentities()) { MERsCustomer =New MERs(); RandomRm =New Random(); Customer. customerid =""+ RM. Next (9999). tostring (); Customer. companyName ="Entlib.com Forum"; Customer. Address =Http://www.EntLib.com"; Mydb. addtocustomers (customer ); IntCount = mydb. savechanges (); Txtcustomerid. Text = Customer. customerid; } 2. Update MERs Record Using(NorthwindentitiesMydb =New Northwindentities()) { VaRQuery =FromCustomerInMydb. MERs WhereCustomer. customerid = txtcustomerid. Text. Trim () SelectCustomer; Foreach(VaRRowInQuery) { Row. companyName ="Updated company name"; } Mydb. savechanges (); } 3. Delete MERs Record Using(NorthwindentitiesMydb =New Northwindentities()) { VaRQuery =FromCustomerInMydb. MERs WhereCustomer. customerid = txtcustomerid. Text. Trim () SelectCustomer; Foreach(VaRRowInQuery) { Mydb. deleteobject (ROW ); } Mydb. savechanges (); } 4. Query MERs , Returns all records Using(NorthwindentitiesMydb =New Northwindentities()) { Datagridview1.datasource = mydb. MERs MERS; }

The followingEntity Framework demoProgram running interface:

In this example Http://forum.entlib.com Open source ASP. NET Forum team. If you have any questions, please visit Http://forum.entlib.com Forum. Download the demo sample program!

 

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.