title: EF - WithOptional - Left Outer Join?
body: <p>With the following one-to-one models, both with navigation properties:-</p>
  <pre><code>public class Foo
  {
      public int Id { get; set; }
      
      public virtual Bar Bar { get; set; }
  }
  
  public class Bar
  {
      public int Id { get; set; }
  
      public virtual Foo Foo { get; set; }
  }
  </code></pre>
  <p><em>Foo</em> has an optional <em>Bar</em>.</p>
  <p><em>Bar</em> has a required <em>Foo</em>.</p>
  <p>I have the following mapping on <em>Bar</em>:-</p>
  <pre><code>HasRequired(x =&gt; x.Foo)
        .WithOptional(x =&gt; x.Bar)
        .Map(x =&gt; x.MapKey(&quot;FooId&quot;));
  </code></pre>
  <p>Which creates the foreign key on the <em>Bar</em> table named 'FooId'.</p>
  <p>All this works fine, except it generates the sql for <em>Foo</em> with a 'Left Outer Join' to <em>Bar</em> on all queries when its not needed.</p>
  <pre><code>SELECT ..
  [Extent2].[Id] AS [Id1]
  FROM  [dbo].[Foo] AS [Extent1]
  LEFT OUTER JOIN [dbo].[Bar] AS [Extent2] ON [Extent1].[Id] = [Extent2].[FooId]
  </code></pre>
  <p>Looking closer it only returns the Bar's Id.</p>
  <p><a href="https://stackoverflow.com/questions/6413063/why-the-left-outer-join">Searching</a> stack I can see most suggestions to use <code>.WithMany</code> instead of <code>.WithOptional</code>, but I need the navigation properties.</p>
  <p>Any suggestions?</p>