title: Problem when inserting two consecutive lines to the database
body: <p>I have this function and it is working perfectly</p>
  
  <pre><code>       public  DemandeConge Creat(DemandeConge DemandeConge)
      {
  
          try
          {
              var _db = Context;
              int numero = 0;
              //??CompanyStatique
              var session = _httpContextAccessor.HttpContext.User.Claims.ToList();
              int currentCompanyId = int.Parse(session[2].Value);
  
              numero = _db.DemandeConge.AsEnumerable()
                            .Where(t =&gt; t.companyID == currentCompanyId)
                            .Select(p =&gt; Convert.ToInt32(p.NumeroDemande))
                            .DefaultIfEmpty(0)
                            .Max();
              numero++;
              DemandeConge.NumeroDemande = numero.ToString();
              //_db.Entry(DemandeConge).State = EntityState.Added;
              _db.DemandeConge.Add(DemandeConge);
              _db.SaveChanges();
  
              return DemandeConge;
          }
          catch (Exception e)
          {
              return null;
          }
      }
  </code></pre>
  
  <p>But just when i try to insert another leave demand directly after inserting one (without waiting or refreshing the page )
  An error appears saying that this new demand.id exists</p>
  
  <p>I think that i need to add refresh after saving changes?
  Any help and thanks</p>