PetaPoco
PetaPoco copied to clipboard
Incorrect AutoIncrement for GUID typed PK
I have a table which has a PK of type GUID and its IsIdentity has been set to false but PetaPoco consider it as true! and I'm getting this exception:
The target table of 'TABLE_NAME' the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
I'm using PetaPoco 5.1.228
@hfakouri Could you provide sample code to reproduce this. I'll add it as an integration test
Create a table in SQL Server and name it Customers. Add a column and name it CustomerCode ([uniqueidentifier] NOT NULL) and set its IsIdentity = false.
Now use T4 templates for generating Database.cs
Generated code would be like this:
[TableName("dbo.Customers")] [PrimaryKey("CustomerCode")] [ExplicitColumns] public partial class Customers : XXXDB.Record<Customers> { [Column] public Guid CustomerCode { get; set; } ... }
and then try to do Save() or db.Insert(). You get the exception.
My hack was I manually edited the generated Database.cs and set the auto increment to false for primary key column:
[TableName("dbo.Customers")] [PrimaryKey("CustomerCode", AutoIncrement = false)] [ExplicitColumns] public partial class Customers : XXXDB.Record<Customers> { [Column] public Guid CustomerCode { get; set; } ... }