IDENTITY_INSERT when create new entity in MSSQL


I’m rewrite old application on Cuba Platform. My entity Client have auto increment ID (IDENTITY FIELD) in MSSQL Database. When I edit entity - all works OK.
But when I try to create new entity then receive SQL error:
SQLException: Cannot insert explicit value for identity column in table ‘Clients’ when IDENTITY_INSERT is set to OFF.

How to solve this problem?
Can I add “SET IDENTITY_INSERT sometableWithIdentity ON” in transaction?
And how to control selection if identity ID number?

Hi! Solved problem by middleware service and Native Query.

Great. You could also use an entity with IDENTITY primary key. It is available in the Id type drop-down in the New entity dialog. The base class of your entity will be BaseIdentityIdEntity in this case.

Thank you, Konstantin.
Changed entities with this type to BaseIdentityIdEntity . It’s better then write workaround service for all entities :wink: