title: How to handle null value in Entity Framework?
body: <p>I am getting maximum code from database but how should I handle it when there is no record? It returns error as null reference no record </p>
  
  <pre><code>int maxCode = context.Persons.Max(p =&gt; p.pCode);
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>This answer is to check first time the null value when you deployed app other wise the suggested answer only match condition with id but i no want to match condition i only have to check weather <strong>there are records in table or not</strong></p>