[英]How to Update the primary key of table which is referenced as foreign key in another table?
[英]how to update a primary key that is also a foreign key in another table with petapoco?
public class User {
public int Id {get;set;}
}
public class Phone {
public int Id{get;set}
public int UserId{get;set;} // foreign key
}
如何使用PetaPoco
更新User.Id
属性? user.Update("set id = @NewId where id = @OldId",new { NewId = new_id,OldId = id});
不工作 。
外键的Sql ON UPDATE CASCADE
选项是最简单的解决方案!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.