これらは私のクラスです
public class Bill
    {
        [Key]
        public int BillID { get; set; }
        [Required]
        public int BillNumber { get; set; }
        [Required]
        public DateTime Date { get; set; }
        [Required]
        public string UserName { get; set; }
        [Required]
        public string Name { get; set; }
        [Required]
        public string Adress { get; set; }
        [Required]
        public string PostalCode { get; set; }
        [Required]
        public string City { get; set; }
        [Required]
        public string Country { get; set; }
        public Bill()
        {
            Date = new DateTime();
            Date = DateTime.Now;
        }
public class Cart
    {
        [Key]
        public int CartID { get; set; }
        [Required]
        public int BillID { get; set; }
        [Required]
        [ForeignKey("BillID")]
        public virtual Bill Bill { get; set; }
        public virtual ICollection<CartItems> Products {get; set;}
    }
public class CartItems
    {
        [Key]
        public int CartItemID { get; set; }
        [Required]
        public Product Product { get; set; }
        [Required]
        public int Qunatity { get; set; }
    }
}
ASP.NET 4 Web アプリケーションを構築しています。カートに商品を追加しようとするとエラーが発生する
エンティティ オブジェクトは、IEntityChangeTracker の複数のインスタンスによって参照できません。
コンテキスト内のカートにカートオブジェクトを追加したいとき。
Bill bill = new Bill();
            bill.BillNumber = Bill.GetLastBillNumber(context) + 1;
            bill.Adress = txtAdress.Text;
            bill.City = txtCity.Text;
            bill.Country = ddlCountry.SelectedItem.Value.ToString();
            bill.Name = txtName.Text;
            bill.PostalCode = txtPostalCode.Text;
            bill.UserName = lblUserName.Text;
            context.Bills.Add(bill);
            context.SaveChanges();
            Cart cart = new Cart();
            cart.Bill = bill;
            cart.BillID = bill.BillID;
            cart.Products = Application["CartProducts"] as List<CartItems>;
            context.Carts.Add(cart);
            context.SaveChanges();
問題について読みましたが、デタッチを行うことができません。それは私にとってはうまくいきません。
DataContext はクラスで privet として定義されています
private DataContext context = new DataContext();
誰かが私を助けることができればお願いします。
どうも。