Closed cdesch closed 4 years ago
I didn't include SQLite because as I know some of the constrains are not enforced but if you find it useful you can send a PR.
I created EntityFramework.Exceptions.Sqlite in this fork but as I saw that you commented, the error codes might not match up. I'll have figure out what the right error codes are.
I think the easiest option is to create a demo database, issue some inserts that cause errors and see what the error codes will be.
@cdesch Any progress?
Closing this due to inactivity. I will reopen it when someone sends a PR.
It seems to me that the codes to catch are the following: https://sqlite.org/rescode.html#extrc
The value to inspect in the SqliteException
is not only SqliteErrorCode
, but also SqliteExtendedErrorCode
For instance for an foreign key exception, I have a (DbUpdateException
with an InnerException set to a) SqliteException
with the following values :
SQLite Error 19: 'FOREIGN KEY constraint failed'.
19
SqliteExtendedErrorCode
= 787
From the sqlite link above, when we have a SqliteErrorCode
with value 19
The SQLITE_CONSTRAINT error code means that an SQL constraint violation occurred while trying to process an SQL statement. Additional information about the failed constraint can be found by consulting the accompanying error message (returned via sqlite3_errmsg() or sqlite3_errmsg16()) or by looking at the extended error code.
And from the same link
SQLITE_CONSTRAINT_FOREIGNKEY (787)
I didn't do any more test, but I think this can help you @cdesch. I may have some time in a few days to try and send a PR if needed.
@Aerion Yes, a PR is welcome
The package is now available at EntityFrameworkCore.Exceptions.Sqlite
Is there a plan to provide support for Microsoft.EntityFrameworkCore.Sqlite? If there is, how can we contribute to it?