title: ASP.net Core (Deployment to IIS) error: An exception occurred while iterating over the results of a query for context type
body: <p>I am getting the following error
  An exception occurred while iterating over the results of a query for context type</p>
  <p>I am very very new to ASP.net in general and I am using entity framework..Can anyone help?</p>
  <pre><code> public IActionResult OnPost()
          {
              if (!ModelState.IsValid)
              {
                  return RedirectToPage(&quot;/Users/Create&quot;);
              }
  
  
              
              var userexists = _context.User.Where(a =&gt; a.Username == User.Username &amp;&amp; a.Password == User.Password);
  
  
              
  
              if (userexists.Count() &gt; 0)
              {
                  Response.Cookies.Append(&quot;userid&quot;, userexists.First().ID.ToString());
  
                  return RedirectToAction(&quot;Index&quot;);
              }else
              {
                  return RedirectToPage(&quot;./Index&quot;);
              }
              
          }
  </code></pre>
  <p>I believe the error is due to the .Where() but I am not sure.
  Please help!</p>