I am trying to map a table with an identity key field. When I try to save I get the error SQL0803 Duplicate key value specified
INSERT INTO libpjk/Audit (AuditId, AuditDate, UserId, Keys, ValBefore, ValAfter, FieldId) VALUES (default, ?, ?, ?, ?, ?, ?)
I'm thinking the AuditId should not appear in the field list and the value of default should not be there either. I just don't know how to do this.
SQL for the table creation:
CREATE TABLE libpjk.Audit (
AuditId integer not null GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),
AuditDate timestamp not null,
UserId char(10) not null,
FieldId integer not null,
Keys varchar(50) not null,
ValBefore varchar(50),
ValAfter varchar(50),
CONSTRAINT libpjk.pk_Audit PRIMARY KEY(FieldId))
Here's how the AuditId is defined in my Audit class:
<Required()> Public Overridable Property AuditId As Integer
here's my mappings:
MyBase.New()
Table("libpjk/Audit")
LazyLoad()
Id(Function(x) x.AuditId).Column("AuditId").GeneratedBy.Identity()
References(Function(x) x.AuditField).Column("FieldId")
Map(Function(x) x.Timestamp).Column("AuditDate").Not.Nullable()
Map(Function(x) x.UserId).Column("UserId").Not.Nullable()
Map(Function(x) x.Keys).Column("Keys").Not.Nullable()
Map(Function(x) x.Value_Before).Column("ValBefore")
Map(Function(x) x.Value_After).Column("ValAfter")
Thanks for your help