title: SQLCE: Why I get "duplicate value" error? The field is identity enabled?
body: <p>In my query I don't use primary key field because identity setting is enabled. </p>
  
  <pre><code>   string sql = @"
                    INSERT INTO [tblTemplates] (personID, hash, data) 
                        VALUES (@personID, @hash, @data)";
  
     cmd = new SqlCeCommand(sql, cn);
     cmd.Parameters.AddWithValue("@personID", newTemplate.personID);
     cmd.Parameters.AddWithValue("@hash", newTemplate.templateHash);
     cmd.Parameters.AddWithValue("@data", newTemplate.templateData);
  
     cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>Randomly I can or cannot insert a record then <strong>an exception thrown</strong>:</p>
  
  <blockquote>
    <p>A duplicate value cannot be inserted into a unique index.<br>
    [ Table name = tblTemplates,Constraint name = PK_<em>tblTemplates</em>_templateID
    ]</p>
  </blockquote>
  
  <p><strong>This is the table schema:</strong></p>
  
  <pre><code>-- Script Date: 26.08.2011 10:37  - Generated by ExportSqlCe version 3.5.1.5
  CREATE TABLE [tblTemplates] (
    [templateID] int NOT NULL  IDENTITY (1,1)
  , [hash] nvarchar(100) NOT NULL
  , [data] image NOT NULL
  , [personID] int NOT NULL
  );
  GO
  ALTER TABLE [tblTemplates] ADD CONSTRAINT [PK__tblTemplates__templateID] PRIMARY KEY ([templateID]);
  GO
  CREATE INDEX [IDX_tblTemplates_personID] ON [tblTemplates] ([personID] ASC);
  GO
  CREATE UNIQUE INDEX [UQ__tblTemplates__templateID] ON [tblTemplates] ([templateID] ASC);
  GO
  </code></pre>
  
  <p>Why I get this error?</p>