title: MVC3 db.SaveChanges() inner exception
body: <p>I am trying to add order list from shopping cart.</p>
  
  <p>I am doing this similarly as <a href="http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-9" rel="nofollow">http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-9</a></p>
  
  <p>db.saveChanges() has error, 'An error occurred while updating the entries. See the inner exception for details.'</p>
  
  <p>When I see the order, orderId is '0'. Is it problem with this?</p>
  
  <p>I am giving you some code.</p>
  
  <p>Could you give me some idea?</p>
  
  <p>Thanks.</p>
  
  <pre><code>//Order.cs
  public class Order
  {
      rentalDB db = new rentalDB();
  
      [Key] public int orderId { get; set; }
      public int customerId { get; set; }
      public DateTime orderDate { get; set; }
      public int rentalPeriod { get; set; }
      public DateTime startDate { get; set; }
      public decimal total { get; set; }
      public virtual Customer Customer { get; set; }
      public List&lt;OrderDetails&gt; OrderDetails { get; set; }
  }
  </code></pre>
  
  <p>And here is controller.</p>
  
  <pre><code>//AccountController.cs
  
  [Authorize]
      public ActionResult Order()
      {
          var order = new Order();
          TryUpdateModel(order);
  
          string customerName = User.Identity.Name;
          if (customerName == "")
          {
              return RedirectToAction("LogOn", "Account");
          }
          int customerId = (from a in db.Customer
                            where a.userName == customerName
                            select a.customerId).Single();
          order.customerId = customerId;
  
          db.Order.Add(order);
          //I added orderDate and startDate, then it is saving now.
          order.orderDate = System.DateTime.Now;
          order.startDate = System.DateTime.Now.AddDays(2);
          db.SaveChanges();
  
          var cart = ShoppingCart.GetCart(this.HttpContext);
          cart.CreateOrder(order);
  
  
          return View(order);
      }
  </code></pre>