SQLite Forum

Can't migrate auto-increment bigint columns
Login
I work on a database that has several bigint (Int64) columns as Ids. We are accessing this through EFCore, and using Sqlite as our in-memory database when running integration tests. Our initial table creation works just fine, but when we make alterations to a table, EF wants to do the whole "make a new table, move the data, drop the old table, rename the new table" dance. which results in the following DDL (Anonymized):

```sql
CREATE TABLE "ef_temp_Thing" (
    "Id" bigint NOT NULL CONSTRAINT "PK_Thing" PRIMARY KEY AUTOINCREMENT,
    "Name" nvarchar(100) NOT NULL,
    "Notes" nvarchar(2000) NULL
);
```

When running the resulting migration, we get the error "SQLite Error 1: 'AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY'" Since this code was auto-generated by EFCore migrations, there's not much I can do about it in general, although I might be able to fix individual migrations one at a time.

If I blow away the database and all migrations, and then create a new migration up from nothing, it will work because this step won't be required. This obviously won't work long-term though, and especially not after v1.0 hits production. I'm also confused by the fact that Sqlite didn't seem to have any problem with the source table being created with an auto-incrementing bigint column in it, so why does it suddenly care when trying to run this migration?