I'm testing the CreateOrUpdate action behaviour.
The primary key is of text type and is a concatenation of other attributes
The first row is inserted with the specified text primary key.
Id: Test1Test2
Attribute1: Test1
Attribute2: Test2
Attribute3: Test3
Then, using the same primary key, a new updated record is created.
Attribute3: Test3-update
When passing this new record to the CreateOrUpdate action, the error is raised - Violation of PRIMARY KEY constraint 'OSPRK_OSUSR_KC0_CREATEORUPDATE3'. Cannot insert duplicate key in object 'dbo.OSUSR_KC0_CREATEORUPDATE3'. The duplicate key value is (Test1Test2).
How to overcome this?
This is the issue:
Your last action is not a CreateOrUpdate: it's a Create. The difference is that it won't try to update an existing record but it will force the database to create a new record. This is what causes your primary key problem.
Switch it to use the second action on that list (CreateOrUpdateCreateOrUpdate) and you shouldn't have any problems.
Hi Nuno,
The CreateOrUpdate Entity actions will always attempt to update existing records. Are you sure you're using CreateOrUpdate instead of Create? Can you show us screenshots of your logic and Entity?
Afonso Carvalho wrote:
Thank you very much Afonso. In attach the files
Both actions in the main flow say "CreateCreateOrUpdate". It's the "Create" part that I'm finding a bit odd.
Can you validate that the Action is indeed a CreateOrUpdate? If it starts with just Create, then it will be the cause of your error.
Would you feel comfortable sharing the application?
Thanks. Sure, here it goes
Thanks Afonso! Next time I'll choose other names for the actions ':)
Yeah, that Entity name is cursed. Lesson learned!
Hello i want one help my application not work when i send message so they generate same error of voilation of primary key, user name james and password is 123, i try to make chat application please help me out from this error.