title: violation of primary key constraint 'pk_'. cannot insert duplicate key in object wpf
body: <p>I used <strong>entity framework code first</strong>.I have 3 tables . my tables are :</p>
  
  <pre><code>-Product :{name id ...}
  
  -property :{name id }
  
  -productProperty:{productId propertyId value}
  </code></pre>
  
  <p>know when I editing my product I want to add new property to this product.
  So my code is : </p>
  
  <pre><code>  listProducts.Remove(curentProduct);
                  curentProduct.productName = txtname.Text;
                  curentProduct.ProductImage = BitmapSourceToByteArray((BitmapSource)imgPhoto.Source);
                  curentProduct.Cat = findCategory(cbCatnewpro.SelectedItem.ToString());
                  curentProduct.productCode = txtProductCode.Text;
                  curentProduct.productInfo = txtInfo.Text;
                  curentProduct.productPrice = txtPrice.Text;
                  curentProduct.productTEdada = Convert.ToInt32(txtTedad.Text);
                  List&lt;dginfocomper&gt; list = new List&lt;dginfocomper&gt;();
                  for (int i = 0; i &lt; dgPro.Items.Count; i++)
                  {
                      dginfocomper d = dgPro.Items[i] as dginfocomper;
                      list.Add(d);
                  }
                  foreach (var item in list)
                  {
                      if (item == null)
                          break;
                      foreach (var item1 in curentProduct.ProductsProperties.ToList())
                      {
  
                          int id = findpropertyId(item.m0);
                          if (id == item1.propertyID)
                          {
                              item1.value = item.m1;
                              break;
                          }
                      }
  
                  }
                  int y = list.Count - curentProduct.ProductsProperties.ToList().Count;
                  int x = curentProduct.ProductsProperties.ToList().Count - 1;
                  for (int i = 0; i &lt; y-1; i++)
                  {
                      ProductProperty pp = new ProductProperty();
                      pp.propertyID = findpropertyId(list[x].m0);
                      pp.value = list[x].m1;
                     curentProduct.ProductsProperties.Add(pp);
                      x--;
                  }
                  listProducts.Add(curentProduct);
                  entity.SaveChanges();
                  dgRowProFill(curentProduct);
                  MessageBox.Show("با موفقیت ثبت شد");
  </code></pre>
  
  <p>But I get below error :</p>
  
  <blockquote>
    <p>{"Violation of PRIMARY KEY constraint 'PK_dbo.ProductProperties'. Cannot insert duplicate key in object 'dbo.ProductProperties'. The duplicate key value is (1, 7).\r\nThe statement has been terminated."}</p>
  </blockquote>
  
  <p>I googling But I cant find my probleam .So How Can I fix it?</p>