To get maximum value of a column that contains integer, I can use the following T-SQL comand
SELECT MAX(expression ) FROM tables WHERE predicates;
Try this int maxAge = context.Persons.Max(p => p.Age);
int maxAge = context.Persons.Max(p => p.Age);
And make sure you have using System.Linq; at the top of your file
using System.Linq;