title: LINQ to Entities causing exception in .NET Core, "Value cannot be null"
body: <p>I'm currently working on trying to convert our companies framework from EF6 to be compatible with EF Core. I've run into a bit of a block. An EF "stored procedure" that works just fine on EF6 is now failing on this block of code in EF Core:</p>
  
  <pre><code>var allFolderAncestors = (from f in context.MENU_MenuFolders
                            from mtf in context.MENU_MenuToolbar_MenuFolders
                                               .Where(x =&gt; x.MenuFolderId == f.Id 
                                                        || x.MenuFolderId == f.ParentFolderId)
                                               .DefaultIfEmpty()
                            where (toolbarId == -1 
                            || (mtf == null 
                                  ? false 
                                  : mtf.MenuToolbarId == toolbarId)
                            ) 
                            &amp;&amp; f.Id != 0
                            select new
                            {
                                AncestorFolderId = f.Id,
                                AncestorParentFolderId = f.ParentFolderId,
                                Id = f.Id,
                                ParentFolderId = f.ParentFolderId
                            }).ToList();
  </code></pre>
  
  <p>Trying to execute this line of code results in the following exception message:</p>
  
  <pre><code>Value cannot be null. Parameter name: left
  </code></pre>
  
  <p>In our .NET Core solution, this code <strong>DOES</strong> work when the input parameter <code>toolbarId</code> is set to -1. So my guess is the problem lies somewhere in the other side of the OR clause. And that's where I'm stuck. I was wondering if anyone has seen this problem before and knows how to fix it? Or how EF Core differs from EF6? I've tried several different fixes and looked in several places for a solution and have come up empty. </p>