Servicestack ORMLite和FirebirdSQL - 自动增量不起作用

时间:2014-02-21 16:56:23

标签: c# ormlite-servicestack firebird2.5

我在C#中的课程Users

public class Users
{
    [AutoIncrement]
    [PrimaryKey]
    public Int32 Id { get; set; }
    [StringLength(100)]
    [Index(Unique = true)]
    public string Username { get; set; }
    [StringLength(250)]
    public string Password { get; set; }

}

我用过:

db.CreateTable<Users>(overwrite: false);

在数据库中创建表。

调试输出显示:

FirebirdSql.Data.FirebirdClient Information: 0 : Command:
CREATE TABLE Users 
(
  Id INTEGER NOT NULL, 
  Username VARCHAR(100), 
  "Password" VARCHAR(250), 
  PRIMARY KEY(Id) 
); 

Parameters:

FirebirdSql.Data.FirebirdClient Information: 0 : Command:
CREATE UNIQUE INDEX uidx_users_username ON Users (Username ); 

Parameters:

FirebirdSql.Data.FirebirdClient Information: 0 : Command:
CREATE GENERATOR USERS_ID_GEN;
Parameters:

但是当我尝试插入记录时,Firebird会抱怨空Id字段。

C#:

db.Insert(new Users { Username = "admin", Password = "passwordhere" });

调试输出:

FirebirdSql.Data.FirebirdClient Information: 0 : Command:
INSERT INTO Users (Username,"Password") VALUES (@Username,@Password)
Parameters:
Name:@Username  Type:VarChar    Used Value:admin
Name:@Password  Type:VarChar    Used  Value:passwordhere

例外:

  

列ID验证错误,值“ * null *

我使用NuGet格式的最新版本。有人可以帮忙吗?

谢谢

0 个答案:

没有答案