Loading ...

Cannot Insert Explicit Value For Identity Column In Table When Identity_insert Is Set To Off In Acumatica

Hello everybody,

today I received the following error message in Acumatica:

Cannot insert explicit value for identity column in table when identity_insert is set to off.

After executing SQL

SET IDENTITY_INSERT table off

problem wasn't solved, so I needed to search deeper. After attaching with SQL Profiler, I noticed that Acumatica generated SQL, which tried to insert null into key field. Then was time to look in manual. 

And then I noticed that for key fields statement IsKey = true is not used. Instead is used 

[PXDBIdentity]

So I replaced [PXDBInt(IsKey = true)] with [PXDBIdentity] and problem disappeared.