开发者

Foreign Keys auto increment does not work in sqlite .NET provider

I insert multiple data into a sqlite table and get always the same ID back. But the field Id is configured as PK + autoinc Id.

I use this as connection string:

public static void SetConnectionString(string dataDataAccessPath)
        {
            _connectionString = String.Format(@"Data Source={0};Foreign K开发者_JAVA技巧eys=ON", dataDataAccessPath);
        }

This "Foreign Keys=ON" was implemented for the connection besides the "PRAGMA foreign_keys = ON;" which had to be executed for every opened connection.

Now I wonder why the new attribute on the connectionstring does not work...

Do I something wrong?


I'm not an expert on SQLite (in fact I have no practical experience with it) but I would imagine that whether or not your IDENTITY fields automatically increment with your insert has something to do more with the definition of the table than with the connection string you are using.

Be reminded that you cannot increment a FOREIGN KEY per se, but rather you need to increment the table with the IDENTITY field that serves as the PRIMARY KEY that the FOREIGN KEY then references.

Can you add the definition of the table that you are having trouble with?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜