我有一张桌子
CREATE TABLE [dbo].[ServiceTestCase](
[SSN] [int] IDENTITY(600000001,1) NOT NULL,
[Description] [varchar](max) NULL,
[EmbeddedResponse] [varchar](max) NULL,
[ResponseType] [varchar](50) NULL,
[DocumentType] [varchar](50) NULL,
[Id] [uniqueidentifier] NOT NULL,
[ServiceType] [varchar](50) NOT NULL,
CONSTRAINT [PK_TestCase] PRIMARY KEY CLUSTERED
我的课
public class ServiceTestCase
{
public ServiceTestCase ()
{
}
public string ServiceType { get; set; }
[ServiceStack.DataAnnotations.AutoIncrement]
public Guid Id { get; set; }
[ServiceStack.DataAnnotations.AutoIncrement]
public long SSN { get; set; }
public string Description { get; set; }
public string EmbeddedResponse { get; set; }
public EmbeddedResponseType ResponseType { get; set; }
public EmbeddedDocumentType DocumentType { get; set; }
}
当我调用 db.Insert ( new ServiceTestCase {/* Id = testId, */ServiceType = "Credit" } ); 我收到以下错误:System.Data.SqlClient.SqlException:当 IDENTITY_INSERT 设置为 OFF 时,无法在表“ServiceTestCase”中插入标识列的显式值。
如何让 ormlite 忽略自动增量字段,以便我可以插入项目?