title: Why can't I get LINQ to work in my .cshtml files?
body: <p>I'm working in VS 2017, targeting .NET Framework 4.6.2, and I've been running into this in a few different projects. I believe the projects were initially created in VS 2012, for what it's worth.</p>
  
  <p>I'm able to use Linq extensions and query syntax with no problems whatsoever in any of the .cs files, but if I try a line like this in a .cshtml razor file: </p>
  
  <pre><code>@{
      var activeCategories =  Model.Categories.Where(x =&gt; x.Articles.Count &gt; 0).Count();
   }
  
  &lt;p&gt;Active Categories: @activeCategories&lt;/p&gt;
  </code></pre>
  
  <p>I get an error like this:</p>
  
  <pre><code>List&lt;Category&gt; does not contain a definition for 'Where', and the closest Extension method 
  accepting a first argument of type List&lt;Category&gt; could not be found (are you missing a 
  using directive or an assembly reference?)`
  </code></pre>
  
  <p>I've tried adding <code>using System.Linq;</code> to the top of the .cshtml files, but it shows an error that it can not be found.</p>
  
  <p>I've updated the <code>Web.config</code> under the Views folder to include <code>System.Linq</code>, I've checked and the project is referencing <code>System.Core</code>, and I've cleared the items in <code>%LOCALAPPDATA%/Microsoft/VisualStudio/15.0_ba2c3fe6/ComponentModelCache</code>.</p>
  
  <p>All philosophy about whether or not to use LINQ in the views aside, this shouldn't be happening, right? This isn't a problem when I create a new ASP.NET MVC project, just with these older projects.</p>
  
  <p>I also am assuming this is something to do with my local environment, as the other devs don't seem to have this issue on their machines.</p>
  
  <p>Why is this happening, and how can I fix it?</p>