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 6355273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:43:54+00:00 2026-05-24T22:43:54+00:00

I have folowing entity [Table(Name = Users)] public sealed class UserDB { private Int64

  • 0

I have folowing entity

    [Table(Name = "Users")]
    public sealed class UserDB
    {
        private Int64 _id = -1;
        private string _username = string.Empty;

        public UserDB() { }

        public UserDB(RepositoryInfo repoInfo)
        {
            UserName = repoInfo.Account;
        }

        [Column(Name = "ID", Storage = "_id",  IsDbGenerated = true, IsPrimaryKey = true, UpdateCheck = UpdateCheck.Never)]
        public Int64 ID { get { return _id; } set { _id = value; } }

        [Column(Name = "UserName", DbType="nvarchar(50)", Storage = "_username")]
        public string UserName { get { return _username; } set { _username = value; } }
    }

ID is mapped to Autoincrement INTEGER type column (actually the only type possible with autoincrement in SQLite)

When I try to add a new user to DB like this, I get an error:

public static Int64 AddUser(DataContext context, RepositoryInfo repoInfo)
{            
    UserDB udb = new UserDB(repoInfo);

    //an ID of udb is -1, but I tried different values too, doesn't change result
    var userstable = context.GetTable<UserDB>();
    userstable.InsertOnSubmit( udb );


    context.SubmitChanges(); // here I get a error, see on screen shot

    return udb.ID;

}

Screen shot of the error:

EDIT
After a googling for and checking, seems that SQLite simply doesn’t provide any SCOPE_IDENTITY() function. But Linq To SQL injects it!

How can I change this?

  • 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-24T22:43:56+00:00Added an answer on May 24, 2026 at 10:43 pm

    Actually there is no solution found by me to resolve this issue, if not that one architectural one => Change linq query to change outputted SQL.

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

Sidebar

Related Questions

I have the following inner class: @Entity @Table(name = SATTET0) public class SATTET0Key {
I have the following entity public class DocumentHistory { public string Name { get;
I have a parent-child relationship: @Entity @Table(name = user) public final class User {
I have the following Entity: @Entity @Table @NamedQuery(name = Constants.FINDALLFINDERNAME, query = Constants.FINDALLQUERY) public
I have the following entity structure: public class Party { public Int32 PartyId {
I have the following classes in my Model: public abstract class Entity : IEntity
I have the following model entity: public class ScheduledTask { public virtual int ScheduledTaskId
Assume I have the following two classes: public class User : Entity { public
I have the following entity: @Entity @Table(name = campaign_content, uniqueConstraints = @UniqueConstraint(columnNames = {
I have the following tables/views Users (View) -> UserId -> Name Roles (Table) ->

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.