title: Cannot insert duplicate key row in object 'dbo.ta_Kullanici' with unique index 'IX_ta_Kullanici'.\r\nThe statement has been terminated
body: <p>I try to develop a program for insert datas from excel table to SqlServer.
  I had an error when I try to insert data to sqlserver. That is my error message here </p>
  
  <blockquote>
    <p>"Cannot insert duplicate key row in object 'dbo.ta_Kullanici' with
    unique index 'IX_ta_Kullanici'.\r\nThe statement has been terminated."</p>
  </blockquote>
  
  <p>ID is unque and autoincrement In my table.</p>
  
  <p>Thanks for your help! :)</p>
  
  <p>A part of my code is here;</p>
  
  <pre><code> if (!check)
                      {
                          kul = new ta_Kullanici();
                          hata = new KullaniciHata();
                          hata.AdSoyad = kullanicilar.Rows[i][7].ToString() + " " + kullanicilar.Rows[i][8].ToString();
                          hatalar.Add(hata);
  
                          kul.kul_ad = kullanicilar.Rows[i][7].ToString();
                          kul.kul_soyad = kullanicilar.Rows[i][8].ToString();
                          foreach (var bolge in bolgeler)
                          {
                              if (kullanicilar.Rows[i][1].ToString().ToLower().IndexOf(bolge.bolge_ad.ToLower()) != -1)
                              {
                                  kul.kul_bolge_Id = bolge.bolge_Id;
                              }
                          }
                          kul.kul_ikTar = DateTime.Now;
                          kul.kul_statu = true;
                          kul.kul_guid = Guid.NewGuid().ToString();
                          kul.kul_ikIP = "127.0.0.1";
                          kul.kul_ik_kul_Id = 5;
                          kul.kul_TCKNo = kullanicilar.Rows[i][9].ToString();
                          kul.kul_kulAd = kullanicilar.Rows[i][6].ToString();
                          kul.kul_tip_enm = 2;
                          if (!string.IsNullOrWhiteSpace(kullanicilar.Rows[i][9].ToString()))
                          {
                              kul.kul_sifre = kullanicilar.Rows[i][9].ToString();
  
                          }
                          else
                          {
                              kul.kul_sifre = "123123";
                          }
  
                          checkList.Add(kul);
                          db.ta_Kullanici.Add(kul);
                          db.SaveChanges();
                          hatalar.Remove(hata);
                      }
  </code></pre>