﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Cannot insert explicit value for identity column</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Fri, 24 Apr 2026 07:01:59 GMT</lastBuildDate><ttl>20</ttl><item><title>Cannot insert explicit value for identity column</title><link>http://forum.strataframe.net/FindPost26039.aspx</link><description>Hi,&lt;br&gt;
&lt;br&gt;
I am getting the following error while trying to insert a record using businessObject1.save():&lt;br&gt;
&lt;br&gt;
Cannot insert explicit value for identity column in table 'MyTable' when IDENTITY_INSERT is set to OFF.&lt;br&gt;
&lt;br&gt;
I tracked the problem and found out that the SQL generated to insert the record has the auto-increment primary id field set to NULL.&lt;br&gt;
&lt;br&gt;
Things I tried:&lt;br&gt;
&lt;br&gt;
1. I setted the ID field to readonly from the Business Object Mapper -&gt; same error&lt;br&gt;
2. I captured the exact SQL, removed the ID field and run it on SQL Server Management Studio -&gt; worked at that run&lt;br&gt;
3. I added the ID field to FieldsToExcludeFromInsert property of the business object -&gt; the application gave the error: Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.&lt;br&gt;
&lt;br&gt;
I compared the business object I created for that application with a business object from the samples - which also has a auto-increment primary key field (cust_pk), and it seems to have the same structure. I didn't see any difference that could be the reason of the problem I am having.&lt;br&gt;
&lt;br&gt;
I am still trying to find the problem, but any help would be very much appreciated.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Buluc</description><pubDate>Tue, 16 Feb 2010 07:39:23 GMT</pubDate><dc:creator>Buluc Celik</dc:creator></item><item><title>RE: Cannot insert explicit value for identity column</title><link>http://forum.strataframe.net/FindPost26063.aspx</link><description>Glad you got it figured out :)</description><pubDate>Tue, 16 Feb 2010 07:39:23 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Cannot insert explicit value for identity column</title><link>http://forum.strataframe.net/FindPost26058.aspx</link><description>Thanks Trent, you pointed to the right direction. I have removed the PK from the FieldsToExcludeFromInsert property, then set PrimaryKeyIsAutoIncremented to TRUE and PrimaryKeyIsUpdatable to FALSE. It is working now :)</description><pubDate>Tue, 16 Feb 2010 00:31:13 GMT</pubDate><dc:creator>Buluc Celik</dc:creator></item><item><title>RE: Cannot insert explicit value for identity column</title><link>http://forum.strataframe.net/FindPost26040.aspx</link><description>If you are doing this through a BO, then you need to set the PrimaryKeyIsUpdatable property to True and the PrimaryKeyIsAutoIncremented to False.</description><pubDate>Mon, 15 Feb 2010 08:49:07 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>