title: (MVC) LINQ to Entities does not recognize the method 'Boolean VerifyHashedPassword(Byte[], System.String)' method
body: <p>When I run my code and there is an error occur over here.Can anyone help me on this? I am new in MVC. Thank you.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public ActionResult Login(AspNetUser user)
          {
              using (eMediCareDBEntities db = new eMediCareDBEntities())
              {
                  //byte[] temp = Convert.FromBase64String("AEh/kUSTE019aDWRoSscnT0c/XArWnjMyBeIgQ1MgTAqRetiD84KgdkFAgHO/bfFKQ==");
  
                  //bool result = VerifyHashedPassword(temp, user.PasswordHash);
  
                  var v = db.AspNetUsers.Single(a =&gt; a.UserName.Equals(user.UserName) &amp;&amp; VerifyHashedPassword(Convert.FromBase64String(a.PasswordHash), user.PasswordHash) == true);
                  if(v != null)
                  {
                      Session["Id"] = v.Id.ToString();
                      Session["UserName"] = v.UserName.ToString();
                      return RedirectToAction("Main");
                  }
                  else
                  {
                      ModelState.AddModelError("", "Username or Password is wrong.");
                  }
              }
              return View();
          }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code</p>
  </blockquote>
  
  <p>Additional information: LINQ to Entities does not recognize the method <code>Boolean VerifyHashedPassword(Byte[], System.String)</code> method, and this method cannot be translated into a store expression.</p>
  
  <p>Error occur at:</p>
  
  <pre><code>var v = db.AspNetUsers.Single(a =&gt; a.UserName.Equals(user.UserName) &amp;&amp; VerifyHashedPassword(Convert.FromBase64String(a.PasswordHash), user.PasswordHash) == true);
  </code></pre>