title: Entity State Value cant be null
body: <p>i have two tables orders and order detail and i have order foriegn key in order detail. and i am inserting ordertotal into order table and all other order info in order details but i am getting this error .please help me out and please tell me hw to use entity state to add values to foriegn key table.</p>
  
  <p><a href="https://i.stack.imgur.com/Gqp5v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gqp5v.png" alt="enter image description here"></a></p>
  
  <p>and here is my saveorder controller function</p>
  
  <pre><code>[HttpPost]
      public ActionResult SaveOrder(FormCollection fc)
       {
          ResturantContext context = new ResturantContext();
          ShoppingCart myCart = (ShoppingCart)Session[WebUtil.CART];
          User u = (User)Session[WebUtil.USER];
          Order order = new Order();
  
  
  
          order.TotalAmount = myCart.TotalAmount;
          new OrderHandler().AddOrder(order);
  
          foreach (var m in myCart.Items)
          {
              OrderDetails od = new OrderDetails();
              od.ID = m.Id;
              od.Price =m.Price;
              od.Product_name = m.Name;
              od.Quantity = m.Quantity;
              od.Address = fc["Address"];
              od.City = fc["City"];
              od.DateOfOrder = DateTime.Now;
              od.UserName = u.FullName;
              od.Email = u.Email;
  
              od.ContactNo = fc["ContactNo"];
              od.Country = fc["Country"];
  
             new OrderHandler().AddOrderDetails(od);
  
          }
          Session.Remove(WebUtil.CART);
          return RedirectToAction("Index","Home");
      }
  </code></pre>