I have the following 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; } }
}
The identifier is mapped to the Autoincrement INTEGER column (in fact, the only type that is possible with auto-increments in SQLite)
When I try to add a new user to a DB like this, I get an error message:
public static Int64 AddUser(DataContext context, RepositoryInfo repoInfo)
{
UserDB udb = new UserDB(repoInfo);
var userstable = context.GetTable<UserDB>();
userstable.InsertOnSubmit( udb );
context.SubmitChanges();
return udb.ID;
}

EDIT
After searching and checking googling, it seems that SQLite simply does not provide any function SCOPE_IDENTITY(). But Linq To SQL inserts it!
How can i change this?
source
share