About Entity Framework Bulk modification of related attribute techniques with DB First mode

Source: Internet
Author: User

The Entity Framework is easier and more convenient to create entities in DB First mode, and it is not a problem to modify the created entities in a few cases, but if you have created more entities, such as more than 10 entities, where there are more modifications, So this time to use a visual editor is no longer so convenient, but should be used in the form of XML to render entity data, and then use our common editing means, copy, paste, cut to quickly implement batch modification, the following is to say the bulk of the method:

1. Locate the file created by the Entity Framework in DB First mode and the file ends with an. EDMX, as shown in:

2. Select the specified edmx file, right-click and select "Open with" in the pop-up menu, as shown in:

3. In the pop-up list, select any method that can be edited in XML and click OK to open the edmx file as XML, as shown in:

Show effect when open:

From the Open XML effect and the generated connectionstring string we can tell that the success of the EF DB first creation will generate three partial content files: *. SSDL (), *. csdl,*. MSL, each part has its own function, namely:

SSDL: Defines some properties within the database (such as the length of a field, etc.)

CSDL: Defining Business Entities

MSL: Defining mappings between business entities and database objects

We can find and modify or replace the corresponding data according to our own needs, and then save it.

I encountered a common batch modification scenario as follows:

1. Modify the schema of the data, this can be modified in SSDL to complete, if not in the form of XML modification, it is necessary to delete all the re-generated entities;

2. Modify the information of a property, such as name, type, etc.;

3. Modify the mapping between the entity and the database field;

About Entity Framework Bulk modification of related attribute techniques with DB First mode

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.