How to Update Entity by Replacing in EF?
<p>I have a class <code>Order</code> which has a <code>List&lt;Item&gt;</code> and a <code>Customer</code>. I need to update <code>Order</code> and its child class. First I only attach the <code>Order</code> object 
but in this way EF cannot Understand changes in <code>Items</code> and <code>Customers</code>. </p>

<p>Then I tried changing the state of the child classes to <code>EntityState.Modified</code> but that didn't work either.Is there a way in EF to replac parent and child classes with existing record in db? </p>

<p>And if there isn't, how can I solve this problem? </p>

<pre><code>var temp = db.Orders.Find(order.Id);
temp = order;
temp.Items = order.Items;
temp.Customer = order.Customer; 
db.SaveChanges(); 
</code></pre>

<p>i try this too after changing Order in user actions: </p>

<pre><code>db.Orders.Attach(order) ;
db.SaveChanges();
</code></pre>