title: Updating record not working in LINQ to SQL
body: <p>I have this sequence generation query that gets the current sequence and increment it to next value. But the increment is not updating. The nextval is always returning 1, the default value from the database</p>
  
  <pre><code>Entity  | StartVal | Increment | CurVal | NextVal
  ----------------------------------------------------
  INVOICE |   0      |     1     |   0    |   1
  </code></pre>
  
  <p>The nextval should be 3, 5, 7 and so on</p>
  
  <pre><code>int nextVal = 0;
  using (var db = new MedicStoreDataContext())
  {
      DAL.LINQ.Sequence seq = (from sq in db.Sequences
                  where sq.Entity == entity
                  select sq).SingleOrDefault();
  
      if (seq != null)
      {
          nextVal = seq.NextVal.HasValue ? seq.NextVal.Value : 0;
  
  
          seq.NextVal = nextVal + 2;
  
          db.SubmitChanges();
      }
  
  }
  </code></pre>
  
  <p>Have I left something undone?</p>
  
  <p><strong>UPDATE:</strong>
  Answer: I needed to set the Primary Key and update Sequence class field to include the Primary Key</p>