title: LINQ Query Issue, Sequence contains no elements
body: <p>I'm trying to update a single record in a table, but when I run <code>.Firstordefault()</code>, I get the error: "Object reference not set to an instance of an object.", and if use it with <code>.First()</code>, I get "Sequence contains no elements".</p>
  
  <p>Using it another place, its working fine, but this time its causing errors.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public class AllownceDetails
  {
    public int ta_id{get;set;}
    public int tvrid{get;set;}
    public DateTime ofDate{get;set;}
    public string status{get;set;}
    public string userid {get;set;}
  }
  //Update Method
  public void Update(AllownceDetails Allowncedtl)
      {
  
          var ta = (from a in ce.tbl_tvrallownce
                    where a.tvrid == Allowncedtl.tvrid 
                     //error: Sequence contains no elements
  
                    select a).SingleOrDefault();
  
          ta.status = Allowncedtl.status; 
                     //error:Object reference not set to an instance of an object
          ce.SaveChanges();
  
  
      }
  </code></pre>