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

  • SEARCH
  • Home
  • 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 8327083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:59:07+00:00 2026-06-09T00:59:07+00:00

I created a sample table on SQLite that has an Id column that is

  • 0

I created a sample table on SQLite that has an Id column that is auto increment.

CREATE TABLE "ESVLIntegration" ("Id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , "ProcessId" TEXT NOT NULL , "UserId" INTEGER NOT NULL , "Status" TEXT NOT NULL , "StartDate" DATETIME NOT NULL , "EndDate" DATETIME, "Operation" TEXT NOT NULL , "SNEquip" TEXT NOT NULL , "CardName" TEXT NOT NULL , "FilePath" TEXT NOT NULL , "Processed" BOOL NOT NULL )

But when I try to insert for the second time, I get the following error:

Abort due to constraint violation PRIMARY KEY must be unique

This is my code

public class ESVLIntegration
{
    public long Id { get; set; }
    public String ProcessId { get; set; }
    public long UserId { get; set; }
    public String Status { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public String Operation { get; set; }
    public String SNEquip { get; set; }
    public String CardName { get; set; }
    public String FilePath { get; set; }
    public Boolean Processed { get; set; }
}

public class Sample : Database<Sample>
{
    public Table<ESVLIntegration> ESVLIntegration { get; set; }
}

private void WriteParameters()
{
    "Writing sample parameters to SQLite DB".LogDebug();
    var pars = new ESVLIntegration();
    pars.ProcessId = Guid.NewGuid().ToString();
    pars.CardName = "gpp3";
    pars.StartDate = DateTime.Now;
    pars.Status = "Start";
    pars.Operation = VerifyStatus;
    pars.SNEquip = "12345";
    pars.FilePath = @"C:\Folder\FilePath";
    pars.Processed = false;
    using (var conn = new SQLiteConnection(connStr))
    {
       conn.Open();
       var db = Sample.Init(conn, 2);
       db.ESVLIntegration.Insert(pars);
    }
}

Any ideas on what I’m doing wrong here ?

EDIT

INTEGER columns on SQlite are of type int64(long)

  • 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-06-09T00:59:09+00:00Added an answer on June 9, 2026 at 12:59 am

    From the SQLite FAQ I found :

    With this table, the statement

    INSERT INTO t1 VALUES(NULL,123);

    is logically equivalent to saying:

    INSERT INTO t1 VALUES((SELECT max(a) FROM t1)+1,123);

    So I just changed my class Id to be nullable

    public class ESVLIntegration
    {
        public long? Id { get; set; }
        public String ProcessId { get; set; }
        public long UserId { get; set; }
        public String Status { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public String Operation { get; set; }
        public String SNEquip { get; set; }
        public String CardName { get; set; }
        public String FilePath { get; set; }
        public Boolean Processed { get; set; }
    }
    

    Now it works great!

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

Sidebar

Related Questions

I have created an SQLite database which has a table which stores temperature values.
Hello Stackoverflowers! I created a simple sqlite DB like so. //event table name private
I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
I'm trying to reindex a table in a simple database that I created using
My database (sqlite3), has two tables with the following schemas: CREATE TABLE log(d date,
i can able to create table to my sqlite data base but i can't
I'm trying to create a migration for a simple table that is just used
I'm building a CGI script that polls a SQLite database and builds a table
I have a pretty simple table in SQLite, with the following schema: CREATE TABLE
I recently created my simple log4net database table for logging via the adonet appender..

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.