private void SuaKH()
{
KhachHang kh = new KhachHang();
kh.MaKH = textBox1.Text;
kh.TenKH = textBox2.Text;
kh.SDT = textBox4.Text;
kh.DiaChi = textBox3.Text;
db.KhachHangs.Attach(kh);
db.Entry(kh).State = EntityState.Modified;
db.SaveChanges();
}
Attaching an entity of type 'WindowsFormsApplication1.Models.KhachHang' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the