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