I'm having trouble trying to use the 'Auto-Sync' feature of DBML with SQLite. I have a class in my data model that contains a primary key (id
). This key is defined as "INTEGER PRIMARY KEY", which SQLite maps to the rowid
of the row. To support this, I have set "Auto Generated Value" to 'True' and "Auto-Sync" to 'OnInsert'.
The problem is, when I commit a new entry to the database, the SELECT
string used by the LINQ to SQL classes is not supported by SQLite:
SELECT CONVERT(BigInt,SCOPE_IDENTITY()) AS [value]
Instead, SQLite has the last_insert_rowid()
function, which I cannot seem to point to.
Does anyone know how to remedy this? Possibly by changing the statement used to select the last row ID or some other trick I'm missing?
EDIT There appears to be some traffic on the provider's website, but no resolutions.
EDIT Since I seem to have confused the question, here's how I've set up my application. Hopefully it helps shed some light on my thought process, and maybe an underlying issue.
- Add new "LINQ to SQL Classes" file to my solution
- Model my database in the designer, named
DataModel
- Open a database using a
System.Data.SQLite.SQLiteConnection
- Initialize the
DataModel
instance using this connection