About how to batch modify attributes of entities created in the database First mode of Entity Framework,
Entity Framework uses the DB First mode to create objects, which is easy and convenient. It is no problem to modify the number of created objects in a small number. However, if there are many created entities, for example, if there are more than 10 objects that involve modification, it is no longer convenient to use a visual editor. Instead, entity data should be presented in XML format, then we use our frequently-used editing methods to copy, paste, and cut to quickly implement batch modification. The following describes the batch modification method:
1. Find the object created by Entity Framework in DB First mode. The object ends with. edmx, as shown in:
2. Select the specified edmx file, right-click it, and select "open mode" from 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 in XML format, as shown in:
The displayed result is as follows:
From the XML open effect and the connectionString generated, we can know that after ef db first is created successfully, three parts of the content file will be generated :*. SSDL (),*. CSDL ,*. MSL, each of which has its own functions:
SSDL: defines some attributes in the database (for example, the length of a field)
CSDL: define business entities
MSL: defines the ing between business entities and database objects.
We can find and modify or replace the corresponding data as needed, and then save it.
Common batch modification scenarios are as follows:
1. Modify the Schema of the data. This can be modified in SSDL. If you do not modify the Schema in XML format, you must delete all and re-generate the objects;
2. Modify the information of an attribute, such as the name and type;
3. Modify the ing between entities and database fields;