Getting started with the Entity framework

Source: Internet
Author: User

recently learned about the technology applied in the project, Entity Framework This part of the content is immediately EF attraction. Now developers are increasingly concerned about how to speed up development efficiency, and EF is undoubtedly worthy of our developers to learn, it is actually Microsoft's ADO enhanced version, is an ORM Framework. Now let's give you a brief introduction to EF.

First, EF Simple Introduction

EF is a ORM - Object Relational Mappings ( object-relationalmapping framework, which can track the changes of entities, maps the objects we use in programming to the underlying database structure.


orm-- Broadly speaking, it refers to the transformation between the object model of the object and the data structure of the relational database; in a narrow sense, ORM is a data storage based on relational database, which realizes a virtual object-oriented data access interface. Ideally, based on such an object-oriented interface, persisting an OO object does not need to know the implementation details of any relational database storage data.


through the graph, we can see that o classes in the corresponding program customer, is the object, we know that r means relational, corresponding to the relational table in the data, M represents the object in the program and the relationship table in the database mapping relationship. Mapping is actually an XML file . ORM does the mapping between relational data and object data,andORM can generate SQL statements automatically through mapping relationships, and ORM acts as a bridge between the business logic layer and the data layer .


Ii. creating the ADO Entity Data Model


The creation process can be divided into three categories:


1. Dbfirst: Create the database First and then map to the entity

2. Modelfirst: Create the Entity Relationship first and then build the database

3, Codefirst: Dependent code generation data relationship


Next, create the data model in Modelfirst mode:


1) First create a console application and then add the ADO Entity Data Model

2) Select the empty EF designer model (if Dbfirst, select the EF designer from the database)

3) Right-click the new entity and attribute in the generated model and contact between entities

4) When the model is built, right-click to generate the database based on the data model.

5) Select the database, verify the identity

6) Generate SQL script after completion, execute script build database


The Dbfirst creation process is to design the database first, then build the entity Design model from the database, and choose to update the model from the database. There is no essential difference between the two approaches, but it is important to note that when there is already a large amount of data in the database, if the database structure is changed, the database is changed and then updated to the model, and if the model is modified and then updated to the database, the data of the database is emptied.




Getting started with the Entity framework

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.