Friday, November 9, 2012

Cannot add an entity with a key that is already in use, LINQ


-- When you get above error there are two possibility

1) you are trying to insert duplicate primary key.
2) when you have SQL column with data type = "Uniqueidentifier" and default set to 'NewID()'
    that means its auto-generated field.

   Make sure in you DBML file that tale > field > properties > "Auto Generated Value"  is set to true
   default is fault

1 comment:

Khushboo Kumari said...

It's solve my issue thanks!!