I have a DB table products
with 5 columns. The Id
is the primary key. In SQL Server Management Studio, you can clearly see this here:
I have a product
with Id
= 69 and Name
= "Lawn Darts" . I am trying to insert a new product with Id
= 420 and Name
= "Lawn Darts". I am trying to use identity insert so that I can specify the Id for products inserted. So the names are the same but the Id is different. This should be no problem, right?
I am using LINQ --> SQL to insert in a C# console app. When I try to insert something with the same Name
but a different Id
, I get the following error message:
Cannot insert duplicate key row in object 'dbo.Products' with unique index 'IX_Name'. The duplicate key value is (Lawn Darts).
Why, if it is a non-key?