ASP. NET MVC Entity Framework additions and deletions

Source: Internet
Author: User

I. Introduction of EntityFramework

ORM (object-relation-mapping): Object-relational mapping, which mainly implements various methods of manipulating database based on object-oriented mode, is a framework technology. C#oop and database operations have been in a state of separation for a long time. The final operations of C # are converted to ordinary SQL statements, which, from a development standpoint, can have a certain impact on rapid development. After Orm comes out: This kind of conversion work is actually done by the ORM framework itself. Complete object-based manipulation data.

. NET ORM Framework:. NHibernate, Mybatis.net, LINQ to SQL, ADO-EntityFramework (now mainstream), enterprise-developed framework.

Second, the advantages of ORM

Rapid development

Easy to migrate databases

Third, the EDM (Entity Data Model): The physical model, which is responsible for mapping the relational database model to the Entity Data model.

EDM structure:
SSDL storage model: What tables are in the database, what fields are in each table, what data type each field is, and what constraints are added to the database
CSDL conceptual model: primarily for entity classes in applications, so this file typically describes entity classes, such as what properties are in a class, what type of each property is
MSL Mapping: This file is mainly the database to the entity class to correspond, such as the entity class of a property corresponding to a database of a column, through this description one by one can be used to map the database table with the application of the visual entity class to do a corresponding

Iv. Basic use of the ORM framework EF

1. Development environment (VS2015, 2013, 2017)

2, through the console program to complete the demonstration.

PS: To learn ef Well, we must first make the LINQ study solid, commissioned.

Five, the Operation procedure

① prepare a database file.

② opening VS2017 Creating a new Console Application

③ in the solution right-click Add New Item, select the ADO Entity Data Model, take a name to add, select the EF designer from the database, next, click New Connection, data source Select SQL Server OK, the server name is selected according to the database. General access to the local database is represented by a dot (.), authentication can be selected by SQL Server or Windows depends on the individual database configuration, select the database that needs to be manipulated, click OK. Check "Yes, include sensitive data in the connection string"! Next, Next ... The content can be checked all tick, completed on it.

④ Open the Main method and write the code

Vi. Inquiries

Seven, new

Viii. modification

Ix. deletion

ASP. NET MVC Entity Framework additions and deletions

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.