Saving updated complex model to complex Entity Framework entities?
<p>I am using Automapper to copy the data from my data objects to my view model objects.</p>

<pre><code>cfg.CreateMap&lt;Customer, CustomerVM&gt;().ReverseMap();
cfg.CreateMap&lt;Order, OrderVM&gt;().ReverseMap();
</code></pre>

<p>There is a navigation property between the <code>Order</code> and the <code>Customer</code>. This works fine for displaying the complex objects on my view.</p>

<pre><code>@Html.EditorFor(a =&gt; a.Customer.AccountName)
@Html.EditorFor(a =&gt; a.Notes)
</code></pre>

<p>And the objects seem to map back properly in my post action. </p>

<pre><code>[HttpPost]
public ActionResult SaveOrder(OrderVM order)
{
        if (ModelState.IsValid)
        {
            var order2 = AutomapperConfig.MapperConfiguration.CreateMapper().Map&lt;OrderVM, Order&gt;(order);
            order2.LastEditDate = DateTime.Now;
            order2.LastEditBy = HttpContext.User.Identity.Name;
            order2.CreateDate = order.CreateDate;

            using (var db = new ProofingContext())
            {                  
                db.Entry(order2).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("index");
            }
        }

        return View();
}
</code></pre>

<p>When I step thru the code in the post action the view model shows the updated data in all the related objects. But when I save the changes I only get the changes to the order saved to my DB. What do I need to do to save the changes to the related objects too?</p>