"Unable to update entityset" ***** ", because it has a definingquery, And the element does not support the element of the current operation ."

Source: Internet
Author: User

When I used entity frame, I found this problem:

"Unable to update entityset" ***** "because it has a definingquery, and Element does not support the current operation Solution to the Problem

 

Testdatasourcedataentities context = new testdatasourcedataentities ();
T_user model = new t_user ();
Model. userid = "gxw1111 ";
Model. Username = "aaaaaaaa ";
Model. userpwds = "123456 ";
Context. addtot_user (model );
Context. savechanges (); // error message

 

 

Puzzling, finally found

1: The table in the object must have a primary key (this indicates that the t_user table must have a primary key). If not, this prompt is displayed.

2: After the primary key is set, a similar problem still occurs during running, which is depressing.

1): Method 1: First Delete the model with the Set primary key from EF, and then add it to EF again, that's OK.

2) If none of the methods are successful, use this more practical method: Create a project and re-associate ef. At this time, this problem is solved or deleted *. the edmx file and the database re-Association have all been tested and passed completely.

 

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.