Entity Framework: include foreign key ID in entity?
<p>I have read in many places that one should (usually) have the foreign key id in an entity because it is a database detail, and in fact, EF manages it pretty well by adding an EntityName_Id column to the corresponding table.</p>

<pre><code>public class Order
{
    public decimal Total { get; set; }
    public int? InvoiceId { get; set; }
    public Invoice Invoice { get; set; }
}

public class Invoice
{
    public ICollection&lt;Order&gt; Orders { get; set; }
}
</code></pre>

<p>In this example, an <code>Order</code> has an optional relationship with <code>Invoice</code>. When showing info about <code>Order</code>, I am interested in knowing whether or not it has an <code>Invoice</code>. <br/>
The problem is that if I don't have the ´InvoiceId´ property in my entities, I have to check the whole related entity just to check if it exists, whereas having that property in my entity would allow me to check it for null, which is "free" in the sense that the entity is already loaded.</p>

<p>Is that the only use of having foreign key Id properties in entities? Am I missing something here?</p>