0

at the line db.SaveChanges(); of the execution. I get the following error.

Note: I am performing an insert.

enter image description here

ERROR :

Cannot insert duplicate key row in object 'dbo.ProductVariant' with unique index 'ProductVarioant_Barcode'.The statement has been terminated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nishant Rambhojun
  • 77
  • 1
  • 2
  • 10
  • 1
    As the error clearly says - obviously, you have a **unique** constraint (or index) on `ProductVariant.Barcode` and you're trying to insert a second row with a duplicate value. Just don't do this . – marc_s Apr 03 '14 at 10:22
  • You must make sure when you insert that in your table the data increments instead of sending yourself ids which can be duplicate and will fail on insertion –  Apr 03 '14 at 10:28
  • edit your question and Shoe your code (write it down here). Code for the insert (hidden below your dialogue in picture) and better to also show your Product_variant class (would be in models) – Sami Apr 03 '14 at 10:49

1 Answers1

1

Error indicates that you are trying to insert a duplicate value inside Barcode column of ProductVariant table. While there is an unique constraint on ProductVariant.Barcode.

John
  • 704
  • 3
  • 12
  • 29