title: EF one to one or zero relationship with custom foreign key column name
body: <p>How do i make the foreign key column to have a custom name. by default EF will append "_" to the foreign key column</p>
  
  <p><strong>Customer</strong></p>
  
  <p><strong>POCO:</strong></p>
  
  <pre><code>public class Customer 
  {
       public int Id { get; set; }
       public string Name { get; set; }
       public virtual Order Order { get; set; }
  }
  </code></pre>
  
  <p><strong>EF Config:</strong></p>
  
  <pre><code>HasKey(m =&gt; m.Id);
  HasOptional(m =&gt; m.Order).WithOptionalPrincipal(e =&gt; e.Customer);
  </code></pre>
  
  <p><strong>Customer table:</strong></p>
  
  <p><pre><code>
  +====+=======+
  | Id | Name  |
  +====+=======+
  | 1  | Cust1 |
  +----+-------+
  | 2  | Cust2 |
  +----+-------+
  | 3  | Cust3 |
  +----+-------+
  | 4  | Cust4 |
  +----+-------+
  | 5  | Cust5 |
  +====+=======+
  </pre></code></p>
  
  <p><strong>Order</strong></p>
  
  <p><strong>POCO:</strong></p>
  
  <pre><code>public class Order
  {
       public int Id { get; set; }
       public string ItemName { get; set; }
       public virtual Customer Customer { get; set; }
  }
  </code></pre>
  
  <p><strong>EF Config:</strong></p>
  
  <pre><code>HasKey(m =&gt; m.Id);
  </code></pre>
  
  <p><strong>Order table:</strong></p>
  
  <p><pre><code>
  +====+=============+==========+
  | Id | Customer_Id | ItemName |
  +====+=============+==========+
  | 1  | 2           | Modem    |
  +----+-------------+----------+
  | 2  | 5           | Router   |
  +====+=============+==========+
  </pre></code></p>
  
  <p>How can i make the Order table as follow (to have "CustomerId" as the actual property name)?</p>
  
  <p><pre><code>
  +====+=============+==========+
  | Id | CustomerId | ItemName |
  +====+=============+==========+
  | 1  | 2           | Modem    |
  +----+-------------+----------+
  | 2  | 5           | Router   |
  +====+=============+==========+
  </pre></code></p>