title: An exception of type 'System.NotSupportedException' thrown in ASP.Net program
body: <p>Im trying to get a list of league games and am getting </p>
  
  <blockquote>
    <p>An exception of type 'System.NotSupportedException'occurred in EntityFramework.SqlServer.dll but was not handled in user code</p>
  </blockquote>
  
  <p>My code for the view is as follows:</p>
  
  <pre><code>public ActionResult viewSchedule(int? id)
  {
      int leagueId = (int)id;
      int seasonYear = getSeasonYear();
  
      League league = db.Leagues.Find(leagueId);
      var leagueGames = db.Games.Where(l =&gt; l.League == league).Where(g =&gt; g.SeasonDate == seasonYear);
  
      return View(leagueGames.ToList());         
  }
  </code></pre>
  
  <p>and the view model is:</p>
  
  <blockquote>
    <p>@model IEnumerable</p>
  </blockquote>