Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 616417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:19:30+00:00 2026-05-13T18:19:30+00:00

I’m using SubSonic 2.2 and sqlite and have encountered a problem when dealing with

  • 0

I’m using SubSonic 2.2 and sqlite and have encountered a problem when dealing with tables with an INTEGER PRIMARY KEY column that isn’t AUTOINCREMENT. According to the faq:

If you declare a column of a table to be INTEGER PRIMARY KEY, then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty.

So sqlite thinks these columns are sometimes auto incremented (ie just when NULL values are provided). The problem is that SubSonic thinks they are always auto incremented.

In my application my ID values are generated from a remote database, so I don’t want to auto-generate them in sqlite. This should be no problem: I’ll simply provide values when I create records in this table. However, when I use SubSonic’s sonic.exe to auto-generate my DAL, the primary key column is set to AutoIncrement = true. This seems to mean that I can’t set the ID column – subsonic’s ActiveHelper.GetInsertCommand() ignores it, since it thinks it’s auto-generated.

The line where it determines whether it’s autoincrement or not is in SubSonic.SQLiteDataProvider.GetTableSchema():

column.AutoIncrement = Convert.ToBoolean(row["PRIMARY_KEY"]) && GetDbType(row["DATA_TYPE"].ToString()) == DbType.Int64;

I guess the solution is either to

  • Not use INTEGER PRIMARY KEY columns for keys that are generated elsewhere, or

  • Modify the templates so these sorts of columns are not set to AutoIncrement = true. This would mean SubSonic won’t ever treat them as auto increment, so I’d need to be careful that I don’t later expect to get auto generated values. Unfortunately I don’t think it’s possible within the templates to easily determine if the column really is AUTOINCREMENT or not, so maybe I’d have to do some ugly hard-coding instead….

Any other thoughts or suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:19:30+00:00Added an answer on May 13, 2026 at 6:19 pm

    Unfortunately it looks like our SQLiteDataProvider assumes that if it’s an Int64 PK, then it’s auto-increment. I’m looking over the source right now (I didn’t write this provider) and I can see that the way the schema is being loaded is using Connection.GetSchema – which uses built System.Data.Common.DbConnection to get the schema for the tables.

    This is suboptimal most of the time because it returns limited information. In this case – it’s not telling us if the column is AUTOINCREMENT or not. There’s probably a better way to ask SQLite the meta information on the table – but it wasn’t used unfortunately.

    Short answer: define a new PK, if you can, and use the other key as a reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 393k
  • Answers 393k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If my guess is correct, your question is......why the following… May 15, 2026 at 2:00 am
  • Editorial Team
    Editorial Team added an answer It's called a toplevel domain (tld) but for the BBC… May 15, 2026 at 2:00 am
  • Editorial Team
    Editorial Team added an answer Oops... I'm stupid. curl -H "X-MYAPP:test" -H "COOKIE:yay" localhost works...… May 15, 2026 at 2:00 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.