In EF, how does one add new fields and mappings to a table? ef Fields

Source: Internet
Author: User

In EF, how does one add new fields and mappings to a table? ef Fields

First understand the ef generated model edmx code, portal: http://www.cnblogs.com/yushengbo/p/4807715.html

1. Add new fields

Let's use the current project as an example. First, create a field in the edmx table:

Then, set the attributes and content, right-click the table, and select display in the Model Browser to go to the Model Browser page:

Right-click the table and select generate database based on the model. In the pop-up box, click "finish". Then, add the corresponding fields to the object class and database table!

2. Add new link ing

To add a table relationship ing, the table must first have an object class. After my observation, this edmx has an object class, but the corresponding database table does not need to add a primary key, right-click any of the two tables that need to be mapped, select "New =" navigation property, right-click the "new property =" property, and modify the name and link. (Multiple factors are one-to-many, and the association selects the table to be associated)

Right-click the new navigation attribute and select table ing:

The ing relationship is displayed. The object key in the table to be associated is on the left, and the field to be associated with the table is selected on the right. If not, follow the steps to create a new one, but this field does not need to be updated to the database table in the Model Browser, that is, there is no need to complete the second step of heading 1, finally, you can add the new fields in the Table above in the corresponding table of the database. You do not need to add fields to the object class!

 

Related Article

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.