The following columns are set to auto-increment in SQL Server IDENTITY(1,1) and I wanted similar behavior on SqLite: Tenant.TenantID, Project.ProjectID, and Credits.CreditsID. Although there is AUTOINCREMENT in SqLite, and I have tried it, but it only works on tables with only 1 Primary Key. I have tried the following testing:
By the way, I used Microsoft.EntityFrameworkCore.Sqlite 2.1.4 for this testing
Explicitly assign value for these columns set to auto-increment:
-
Tenant.TenantIDa. -99 : remains -99 after saving
b. 0 : becomes 1 after saving
c. 99 : remains 99 after saving
-
For
Project.ProjectID&Credits.CreditsIDa. -99 & 99 values remains the same after saving changes to DbContext. But I do not want to explicitly assign these values because there are bunch of test data from my DbContext.
b. Assigning explicit value 0 throws this error:
Microsoft.Data.Sqlite.SqliteException : SQLite Error 19: 'NOT NULL constraint failed: Credits.CreditsID'.
I'd really be grateful for someone who can help me out with this one. It's been days that this bothers me.

Aucun commentaire:
Enregistrer un commentaire