title: Using max() function with entity framework throws an exception
body: <p>So I need to get the max value of a column (or the last one) using entity framework and both of these queries throw exceptions:</p>
  
  <p>(The ID I'm trying to retrieve is of type varchar, but it works in raw sql, I think
  it should work here too)</p>
  
  <p>This one:</p>
  
  <pre><code>string maxCurrentID = db.reservations.Max().ReservationID;
  </code></pre>
  
  <p>Throws this:</p>
  
  <p>The specified method 'EntityClub_.reservacion Maxreservacion' on the type 'System.Linq.Queryable' cannot be translated into a LINQ to Entities store expression because no overload matches the passed arguments.</p>
  
  <p>and this one:</p>
  
  <pre><code> string maxCurrentID = db.reservations.LastOrDefault().ReservationID;
  </code></pre>
  
  <p>LINQ to Entities does not recognize the method 'EntityClub_.reservacion LastOrDefaultreservacion' method, and this method cannot be translated into a store expression.</p>
  
  <p>How can I obtain the expected values?</p>