In SQLite:
If a table contains a column of type INTEGER PRIMARY KEY, then that column becomes an alias for the ROWID.
When a new row is inserted into an SQLite table, the ROWID can either be specified as part of the INSERT statement or it can be assigned automatically by the database engine.
If no ROWID is specified on the insert, or if the specified ROWID has a value of NULL, then an appropriate ROWID is created automatically.
I created a table in SQLite with an integer primary key, and then opened the file in LINQPad. I'm trying to insert a new row into the table via C#:
var episode = new RateableItem()
{
SourceId = "tal",
Edition = episodeNum.ToString(),
Name = episodeName,
Consumed = false
};
RateableItems.InsertOnSubmit(episode);
SubmitChanges();
In the above example, I haven't specified the pimary key. This fails because LINQPad has mapped the primary key to a non-nullable int, so the generated SQL inserts a 0 into the primary key, which fails because a row with PK 0 already exists.
Is there a way to configure LINQPad with SQLite so that it passes a null for the PK, allowing SQLite to automatically assign the PK value?