title: EFCore returning too many columns for a simple LEFT OUTER join
body: <p>I am currently using EFCore 1.1 (preview release) with SQL Server.</p>
  
  <p>I am doing what I thought was a simple OUTER JOIN between an <code>Order</code> and <code>OrderItem</code> table.</p>
  
  <pre><code>      var orders = from order in ctx.Order
                     join orderItem in ctx.OrderItem
  
                     on order.OrderId equals orderItem.OrderId into tmp
  
                     from oi in tmp.DefaultIfEmpty()
  
                     select new
                     {
                         order.OrderDt,
                         Sku = (oi == null) ? null : oi.Sku,
                         Qty = (oi == null) ? (int?) null : oi.Qty
                     };
  </code></pre>
  
  <p>The actual data returned is correct (I know earlier versions had issues with OUTER JOINS not working at all). However the SQL is horrible and includes every column in <code>Order</code> and <code>OrderItem</code> which is problematic considering one of them is a large XML Blob.</p>
  
  <blockquote>
    <p>SELECT [order].[OrderId], [order].[OrderStatusTypeId],
    [order].[OrderSummary], [order].[OrderTotal], [order].[OrderTypeId],
    [order].[ParentFSPId], [order].[ParentOrderId],
    [order].[PayPalECToken], [order].[PaymentFailureTypeId] ....</p>
    
    <p>...[orderItem].[OrderId], [orderItem].[OrderItemType], [orderItem].[Qty],
    [orderItem].[SKU] FROM [Order] AS [order] LEFT JOIN [OrderItem] AS
    [orderItem] ON [order].[OrderId] = [orderItem].[OrderId] ORDER BY
    [order].[OrderId]</p>
  </blockquote>
  
  <p><em>(There are many more columns not shown here.)</em></p>
  
  <p>On the other hand - if I make it an INNER JOIN then the SQL is as expected with only the columns in my select clause:</p>
  
  <blockquote>
    <p>SELECT [order].[OrderDt], [orderItem].[SKU], [orderItem].[Qty] FROM
    [Order] AS [order] INNER JOIN [OrderItem] AS [orderItem] ON
    [order].[OrderId] = [orderItem].[OrderId]</p>
  </blockquote>
  
  <p>I tried reverting to EFCore 1.01, but got some horrible nuget package errors and gave up with that.</p>
  
  <p>Not clear whether this is an actual regression issue or an incomplete feature in EFCore. But couldn't find any further information about this elsewhere.</p>
  
  <hr>
  
  <p>Edit: EFCore 2.1 has addressed a lot of issues with grouping and also N+1 type issues where a separate query is made for every child entity. Very impressed with the performance in fact. </p>
  
  <p>3/14/18 - 2.1 Preview 1 of EFCore isn't recommended because the GROUP BY SQL has some issues when using OrderBy() but it's fixed in nightly builds and Preview 2.</p>