Force value on PK with autoincrement

Posts   
 
    
OSSistemes
User
Posts: 20
Joined: 20-Nov-2019
# Posted on: 24-Oct-2024 21:58:25   

Hi Team,

I have some problem trying to sync to databases. I have entity with GUID as PK (no problem here) but this parent entity have subentity with PK Autoincrement, when I merge origin with destiny, some times ID between databases are no the same and I always do DELETE / INSERT instead of UPDATE, because the ID between subentity are not the same, and it's no possible to sync with ID, are different!!!

Please If possible to force PK (AUTOINCREMENT) when flag isNew on subentity?

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39729
Joined: 17-Aug-2003
# Posted on: 25-Oct-2024 18:47:03   

If I understand you correctly, you want to to insert rows from database A into database B and the table in database B has an autoincrement/identity PK so inserting the value from A wont' work, because you can't insert the value from A? (as it will autogenerated by B).

In SQL Server you can set a setting to ON https://learn.microsoft.com/en-us/sql/t-sql/statements/set-identity-insert-transact-sql?view=sql-server-ver16 which will then allow you to insert the values. However if your A and B databases go out of sync, it might be better to simply see B as a copy of A so B follows A, with a PK that's no autoincrement/identity? This might require a different entity model to work with database B however, as you can't switch identity inserts off in our framework at runtime.

Frans Bouma | Lead developer LLBLGen Pro