title: How do I get the max ID with Linq to Entity?
body: <p>I have a table User which has an identity column <code>UserID</code>, now what is the correct Linq to Entity line of code that would return me the max <code>UserID</code>?</p>
  
  <p>I've tried:</p>
  
  <pre><code>using (MyDBEntities db = new MyDBEntities())
  {
      var User = db.Users.Last();
      // or
      var User = db.Users.Max();
  
      return user.UserID;
  }
  </code></pre>
  
  <p>but <code>Last</code> and <code>Max</code> don't seem to be supported.</p>
  
  <p>Any ideas?</p>