简体   繁体   中英

Update Id Primary Key field with C#

Hai, like the title.. I just wanna make sure how if I want to update primary key in LINQ? I did google and found that it`s impossible to update Id in Linq. the other way is I delete the old record and insert new but the problem is it will be not effective if the table has a relationship with other table..maybe someone give me a better way to solve it.

Thanks in advance

If there are dependent rows in another table then you either need to enable the ON UPDATE CASCADE option on the foreign key constraint(s) OR you need to update TWO rows simultaneously. Otherwise you will get a constraint violation error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM