title: SQL Server CE Insert into table doesnt seem to increment identity
body: <p>I have a table defined like this:</p>
  
  <pre><code>CREATE TABLE ItemCategory
  (
      ID INT IDENTITY NOT NULL PRIMARY KEY,
      CategoryID INT NOT NULL,
      ItemID INT NOT NULL
  );
  </code></pre>
  
  <p>This table links to two tables on the two foreign keys.</p>
  
  <p>I have this SQL statement</p>
  
  <pre><code>INSERT INTO ItemCategory (CategoryID, ItemID) 
  VALUES (@category, @item)
  </code></pre>
  
  <p>with the parameters being set as follows:</p>
  
  <pre><code>var p1 = new SqlCeParameter("@category", SqlDbType.Int);
  var p2 = new SqlCeParameter("@item", SqlDbType.Int);
  p1.Value = categoryID;
  p2.Value = itemID;
  </code></pre>
  
  <p>The values of the parameters are correct (I have debugged and checked) therefore there shouldn't be any foreign key errors.</p>
  
  <p>When I execute the SQL statement I get the following error:</p>
  
  <blockquote>
    <p>The column cannot contain null values. [ Column name = ID,Table name = ItemCategory ]</p>
  </blockquote>
  
  <p>However I don't understand this as the <code>ID</code> column is set as an <code>Identity</code> column and therefore I should not have to supply a value and it should be auto incremented automagically.</p>
  
  <p>Why could this be?</p>
  
  <ul>
  <li>C#</li>
  <li>SQL Server Compact Edition 4.0</li>
  <li>Visual Studio 2012</li>
  </ul>