Entity Framework inserts row without me calling AddToObject()?
问题 Okay, so it's late and I'm tired, but this shouldn't be happening... or so I believe. I have the following code for an event handler for a button click where I create a new customer from a web form. int customerId = <from_somewhere_doesnt_matter>; Customer cust; if (int.TryParse(Request.QueryString["cid"], out customerId)) { // update existing customer cus = db.Customers.Single(c => c.CustomerId == customerId); cus.UpdatedByUser = user; cus.Updated = DateTime.Now; } else { // create new