if (creditRent.mast_be_pay_credit >= payCount) { PaymenResultEntity pre = new PaymenResultEntity(); creditRent.mast_be_pay_credit -= payCount; creditRent.how_much_to_pay_Credit += payCount; PaymenResult pr = new PaymenResult(0, "Dont error"); pre.error_cod = pr.errorCode; pre.error_description = pr.errorDescrip; pre.date_of_rent = DateTime.Now; pre.payment_ID = paymentId; sde.SaveChanges(); } 

Good day!
Here I have this code, but when I try to sde.SaveChanges(); an exception occurs with such a message. Help solve this problem.

Anonymous of type 'System.InvalidOperationException' occurred in EntityFramework.dll but it was not handled in user code.
Additional information: The property 'how_much_to_pay_Credit' is part.

    1 answer 1

    You do not have a primary key in the table. Or did you put him like that? If a primary key is not specified, then EF takes nonzero columns and, based on them, determines the primary key, and the entity itself becomes readable. Therefore, set the table primary key and the problem goes away.