谁给个
try {
db.Attach(entity);
}
catch (Exception) {
//如果entity本来就已经是Attached,则这里会有异常,具体应该一个是InvalidOperationExcetion,还有一个忘记了,可以自己查看
finally {
db.SubmitChanges();