Failed to retrieve the automatically incremented column value from the server.
Possible reason: A trigger does not perform 'select ID from inserted' as last operation.
The DDL from the table:
CREATE
TABLE
[Communications].[DomainPart](
[PartID] [
bigint
] IDENTITY(1,1)
NOT
NULL
,
[ParentPartID] [
bigint
]
NULL
,
[PartText] [
varchar
](64)
NOT
NULL
,
CONSTRAINT
[PK_DomainPart]
PRIMARY
KEY
CLUSTERED
(
[PartID]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
The code performing the insert:
using
(var context =
new
Data.GlobalResourcesEntitiesModel())
{
foreach
(
string
part
in
parts)
{
// Try to load existing item
if
(lastItem ==
null
)
{
curItem = context.DomainParts.Where(p => p.ParentPartID.Equals(
null
) &&
p.PartText.Equals(part, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
}
else
{
curItem = context.DomainParts.Where(p => p.ParentPartID.Equals(lastItem.ParentPartID) &&
p.PartText.Equals(part, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
}
// If item exists then continue
if
(curItem !=
null
)
{
lastItem = curItem;
continue
;
}
// Attempt to create it
curItem =
new
DomainPart()
{
PartText = part
};
if
(lastItem !=
null
) { curItem.ParentPartID = lastItem.PartID; }
context.Add(curItem);
context.SaveChanges();
if
(curItem.PartID <= 0) {
return
null
; }
lastItem = curItem;
}
}
Thanks, in advance.
- Greg D.
18 Answers, 1 is accepted

else
{
curItem = context.DomainParts.Where(p => p.ParentPartID == lastItem.PartID &&
p.PartText.Equals(part, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
}
thanks for reporting this issue. We've identified a path where the original exception from the server could be missed, and will fix this for the next version.
Greetings,
Thomas
the Telerik team

Hello, we are receiving the same error after we applied MS15-058 SQL Server patch on SQL 2012. When we roll back the patch, it is working fine.
" Failed to retrieve the automatically incremented column value from the server.
Possible reason: A trigger does not perform 'select ID from inserted' as last operation.​"
it seems you are using an older version of OpenAccess; is that information right? A colleague of mine tried to reproduce the same issue here (with installed server patch), but could not get into the problem with newer versions of OpenAccess.
In case you are using an older version, can you update and try again?
Regards,
Thomas
Telerik

Hello Thomas,
Thanks for the quick reply. We are currently using version 2013.2.702.1. Is it possible your team can try using this version (with the server patch) and confirm the issue ?
Thanks
Jay
we have been trying to reproduce this with the exact version that you mentioned with the server path, but we had no success in doing so. Is it possible to give us a reproduction case?
Regards,
Thomas
Telerik

Hello Thomas,
My colleague has already created a support ticket 962788.
We do have an environment we are able to reproduce the issue. Can we setup a web-ex so we can demo the issue ?
Thanks
Jay
thanks to your colleague for sending us a reproduction code. We are looking into this and will let you know about the outcome.
Regards,
Thomas
Telerik
we identified this to be caused by a changed version format string (from the applied patch) that fools our runtime. We plan to release a fixed version (via NuGet) soon, probably during next week.
We apologize for the inconvenience this has caused.
Thomas
Telerik

We have uploaded hotfix release for Telerik Data Access NuGet packages that you can get from www.nuget.org. The latest patched package is versioned as 2015.2.624.2. Please update all your existing Telerik Data Access packages to that version.
If you are using previous version of our NuGet packages and you have concerns about updating to the latest, please let us know so we can give you a hand in the process.
Regards,
Viktor Zhivkov
Telerik

Hi Viktor,
Is there any prospect of a hotfix for the 2015.1.* version of Data Access to fix this for people like me who are locked into this version for the medium-term due to the scale of rework required to migrate to the new approach? I have been hit by the bigint INSERT issue out of the blue today following an upgrade of a SQL 2012 database. I now face having to alter the datatype of the primary key on every table in the system to get things working again​.
Thanks,
Matt.
Introducing such a patch for Data Access Q1 2015 is a topic that we intend to discuss. I'll make sure to update this thread with the appreciate information once I have it.
Thank you for your understanding.
Regards,
Doroteya
Telerik
There's a hot fix for the Telerik.OpenAccess.Runtime assembly version 2015.1.225. You can find it attached to this message. In order to use it, you need to paste the new assembly in the install folder of Data Access on your machine and to install it in GAC (overwriting the existing one). Once you do this, make sure to clean your solution and rebuild it. Additionally, when you decide to deploy your applications make sure that they are configured as described in this blog post.
As a note, you will have to perform the same process again if you install Data Access Q1 2015 on another machine or if you re-install it.
I hope this helps. Let me know if you have further questions.
Regards,
Doroteya
Telerik

Dear support,
we're currently referencing version 2012.2.607.1 of the Telerik.OpenAccess assemblies in our projects.
Now we're faced with the identical effect when installing the Windows Update KB3162659.
As you point out in the readme file of the hotfix, the issue is not limited to this specific Windows Update. Any update for different SQL server versions that converts the SQL version format string to the not supported forma, breaks the Telerik runtime.
Is there also a hotfix for the mentioned assembly version 2012.2.607.1.
Are there other options of how to overcome this issue besides updating to Telerik version 2015 and then apply the hotfix?
Please let me know, if you require more detailed information.
Best regards,
Markus

Dear support,
we are also using 2012.2.628.2 - and getting this error now on a SQL 2008 R2 (10.50.6542)
If you have any recommendations in upgrading, go ahead. We use a single context for the whole lifetime in a WinForms UI - somebody told me that this is a problem.
We also rely on the designer heavily ... so we have to use the last version where designer is supported.
Thanks in advance!
Our general recommendation for situations like those you describe is to upgrade Data Access to at least Data Access Q1 2015, and to install the available hotfix (more details are available in this forum post). Note that, although there's a hotfix for this version it supports Visual Studio up to version 2013.
The more permanent solutions that will allow you to update your applications in a more convenient way in the feature are described in the options listed in this forum post.
I hope this helps.
Regards,
Doroteya
Telerik by Progress

Is it possible at all to have this hotfix and its details more visible? I've been casting about for a week trying to find a solution to this exact issue after 3 different versions of my product started failing on SQL 2012. I overlooked this thread multiple times because the thread wasn't originally about this issue and seemed to be a user error. It was only as a last resort that I finally read down through and realized the thread had been repurposed for exactly my issue and had the solution all along.
At the very least a message or something that would appear in users' Telerik account page or downloads stating 'If on SQL 2012 and inserts fail with Telerik prior to Data Access Q1 2015' or similar would be greatly helpful to other customers who may encounter this and be unable to immediately move to a fluent model.