I ran into this error when trying to do an insert:
Cannot insert the value NULL into column 'Id'
It turns out PetaPoco by default assumes the Id column is auto increment, so even if you provide a value it will attempt to insert null instead. I found a bug ticket for the problem here: https://dnntracker.atlassian.net/browse/DNN-23217.
I'm using PetaPoco's T4 template to generate my database classes. I created a partial class an applied the data annotation to disable auto increment:
[PrimaryKey("Id", autoIncrement = false)]
public partial class Blah : DatabaseDB.Record<Database.Blah>
{
}
However it seems to have no effect. PetaPoco is still trying to insert null for the Id column when I am specifying an integer.