Pakeeza

Pakeeza

  • 1.6k
  • 93
  • 2.8k

How to modify one column of a table which is used as composite key

Feb 25 2024 6:38 PM

Dear I have a table in which I have made a primary key as combination of three columns like (ID,Student_branch,School_branch) 

Now I am getting all data from the table by giving a student_ID parameter and i get one row which is fine now I want to add only school Branch column when I call this 

studnet.School_branch= "ABC";
                      
                        db.Entry(School_branch).State = System.Data.Entity.EntityState.Modified;

                        db.SaveChanges();

 I get this error The property 'School_branch' is part of the object's key information and cannot be modified.


Answers (4)