I have a table that contains a “uniqueidentifier”, which defaults to “00000000-0000-0000-0000-000000000000” (Guid.Empty) via default value on SQL Server when no value is provided.
With PetaPoco, i’m creating a GUID, and using db.Insert() to insert my object.
My class that represents that table, looks like:
[PetaPoco.TableName("my_table")]
[PetaPoco.PrimaryKey("my_id")]
public class FaveColors
{
[PetaPoco.Column(Name = "my_id")]
public int myId { get; set; }
[PetaPoco.Ignore]
public string myFavouriteColor { get; set; }
[PetaPoco.Column(Name = "my_guid")]
public Guid myGuid { get; set; }
}
The only other advice i can find relates purely to when the UniqueIdentifier is the PK, in which case you set auto-increment to be off… However, in my case, this is not the PK.
What can i do to actually sent the correct GUID via PetaPoco into the DB?