When to store just the ID in a class vs storing a fully-populated object?
<p>Let's say I have two tables as below:</p>

<pre>
FoodType:

ID | Name       |  ... additional fields ...
---------------------------------------------
1  | Fruit      | ...
2  | Vegetable  | ...
</pre>

<pre>
Food:

ID | FoodTypeId | Name
----------------------
1  | 1          | Apple
2  | 1          | Orange
3  | 2          | Carrot
4  | 2          | Spinach
5  | 1          | Pear
</pre>

<p>When I'm structuring a class for <code>Food</code>, in what cases would it be better to define just <code>FoodTypeId</code> instead of a whole <code>FoodType</code> object?</p>

<p>i.e.</p>

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

<p>vs</p>

<pre><code>public class Food
{
    public int Id {get; set;}
    public FoodType FoodType {get; set;}
    public string Name {get; set;}
}

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