Best way to detect unique index violation?

14 views
Skip to first unread message

Kjell Rilbe

unread,
May 17, 2022, 8:30:47 AM5/17/22
to firebird-n...@googlegroups.com

Hi,

In our EF Core application code we would like to detect violations of unique index or primary key.

In the thrown DbUpdateException (or some inner exception), what should we check?

Mvh,
Kjell



Kjell Rilbe
Telefon: 0733-44 24 64

Marknadsinformation i Sverige AB
Sundbybergs Torg 1 H 7 tr
172 67 Sundbyberg, Sweden
www.marknadsinformation.se
08-514 905 90

Företagskontakt.se Personkontakt.se DI Gasell 2018 DI Gasell 2019
kjell_rilbe.vcf

Jiří Činčura

unread,
May 18, 2022, 3:31:38 AM5/18/22
to 'Mr. John' via firebird-net-provider
Hi, I suppose you're talking about `violation of PRIMARY or UNIQUE KEY constraint "XXX" on table "XXX"`. If so the best way is to check inner exception of FbException and check the error code for `335544665`.

--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/

Kjell Rilbe

unread,
May 18, 2022, 3:36:31 AM5/18/22
to firebird-n...@googlegroups.com
Den 2022-05-18 kl. 09:31, skrev Jiří Činčura:
> Hi, I suppose you're talking about `violation of PRIMARY or UNIQUE KEY constraint "XXX" on table "XXX"`. If so the best way is to check inner exception of FbException and check the error code for `335544665`.

Yes, that would be the one. :-) Thanks!

Kjell
kjell_rilbe.vcf
Reply all
Reply to author
Forward
0 new messages