first of all happy new year to all !!!!
i have following code to remove a record from the db table tr_shoppingCart
tr_ShoppingCart cart = new tr_ShoppingCart
{
cartId = sc.CartId,
CartGenDt = sc.CreateTime,
UserId = ((SessionData)Session["object"]).sessObj.UserId,
prodId = obj.prodId,
Qnty = obj.Qnty,
Total = obj.Total
};
if (ModelState.IsValid)
{
//db.Entry(cart).State = System.Data.EntityState.Deleted;
db.tr_ShoppingCart.Attach(cart);
db.tr_ShoppingCart.Remove(cart);
db.SaveChanges();
}
but it has given the error:
An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.
here is my DB table tr_ShoppingCart