title: ViewModel objects child is null on POST
body: <p>I have a viewmodel, with two properties, one is a POCO class, the other is a double, when the controller builds and send the viewmodel out all the values are present and working on the page. When I POST the viewmodel the double value is set, and the object is present but the POCO class inside is null, which was not when the object is sent.</p>
  
  <p>In the examples below, why is <code>ticket.flight</code> null on the POSTed viewmodel object?</p>
  
  <p>ViewModel:</p>
  
  <pre><code>public class PayViewModel
  {
      public virtual Ticket ticket { get; set; }
      public double amountToPay = 0.0;
      [Display(Name = "Amount To Pay")]
      [DataType(DataType.Currency)]
      [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)]
      public double AmountToPay
      {
          get
          {
              return amountToPay;
          }
          set
          {
              amountToPay = value;
          }
      }
  }
  </code></pre>
  
  <p>Controller methods:</p>
  
  <pre><code>// GET: Tickets/Pay/5
  public ActionResult Pay(int? id)
  {
      if (id == null)
      {
          return RedirectToAction("Index");
      }
      Ticket ticket = db.tickets.Find(id);
      if (ticket == null)
      {
          return RedirectToAction("Index");
      }
  
      PayViewModel viewModel = new PayViewModel();
      viewModel.ticket = ticket;
      return View(viewModel);
  }
  
  // POST: Tickets/Pay/5
  [HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Pay([Bind(Include = "AmountToPay,ticket,ticket.flight")]PayViewModel viewModel)
  {
      if (ModelState.IsValid)
      {
          viewModel.ticket.AmountPaid += viewModel.AmountToPay;
          if (viewModel.ticket.AmountPaid &gt;= viewModel.ticket.flight.ticketPrice)
          {
              viewModel.ticket.status = TicketStatusType.CONFIRMED;
          }
          db.Entry(viewModel.ticket).State = EntityState.Modified;
          db.SaveChanges();
          return RedirectToAction("Index");
      }
      return View(viewModel.ticket);
  }
  </code></pre>
  
  <p>View code - <a href="https://gist.github.com/JonFriesen/f511a91b8e9a90c1b23c" rel="nofollow">https://gist.github.com/JonFriesen/f511a91b8e9a90c1b23c</a></p>