Auto mapping one to one foreign keys in asp.net boilerplate
<p>Suppose I have the following class structure:</p>

<pre><code>public class Pizza
{
    public int Id { get; set; }
    public virtual PizzaType PizzaType { get; set; }
}

public class PizzaType
{
    public int Id { get; set; }
    public string Name { get; set; }
}
</code></pre>

<p>Now, I need a DTO class so I can pass to the UI an object for edit, and then pass back to the service for saving to the database. Thus:</p>

<pre><code>[AutoMap(typeof(Pizza))]
public class PizzaEdit
{
    public int Id { get; set; }
    public int PizzaTypeId { get; set; }
}
</code></pre>

<p>The goal is to map between <code>Pizza</code> and <code>PizzaEdit</code> as easily as possible so it can be edited in the UI and saved back to the database. Preferably, this will "just work".</p>

<p>What do I need to do to get a mapping from <code>Pizza</code> to <code>PizzaEdit</code> to work and include <code>PizzaTypeId</code> in the DTO object?</p>

<p><code>pizzaObj.MapTo&lt;PizzaEdit&gt;()</code> works but <code>PizzaTypeId</code> is always null.</p>

<p>I'm open to changing the class structure as needed.</p>