I use LINQ to SQL. I have simple one attribute table in SQL Server, this attribute is also primary key. Here is the table structure (screenshot from Visual Studio 2012)
I use linq to create corresponding entities from List<string>
.
This entity's one and only attribute is token
. I traverse through the List<string>
(this is deserialized from a xml file), and create Token
entity and set its token attribute to a string from List and call InsertOnSubmit
.
After populating the Token
table, I call SubmitChanges
on context. At this point I get error that I have primary key violation on some string, let it be bla bla
.
I've checked several times inside my xml file (from which I've deserialized my List<string>
) that I have only one bla bla
. I've tried to remove this bla bla
from string, after I do that, I get the same error on other string, and again check the file and again I have only one of that string inside the file.
I even checked inside the code the count of elements which contain string bla bla
, and again there count is only 1. I don't know from where LINQ takes another instance of "bla bla" and I got really angry. Of course I've checked that I call InsertOnSubmit
only one time inside my code for every string. So I have no idea why I continue to get this primary key violation on "bla bla".
Any suggestions??
Thanks for the answers