Say I need a table that looks like this:
CREATE TABLE Record (
Id INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
Guid UNIQUEIDENTIFIER UNIQUE NONCLUSTERED,
Version ROWVERSION,
DateOfBirth DATETIME2,
Name VARCHAR(64) NOT NULL
)
What's the recommended way of creating the table above using PetaPoco and NPoco?
PetaPoco is all about using SQL for what SQL does best. Therefore, the correct way to create a table with PetaPoco is to create it with SQL. We've had a few requests to add schema generation from POCOs, but every supported DB has their own take on DDL, and thus to add it (properly) would be a big undertaking.
It may be added some day, but right now development time is better spent on other features.
That said, PetaPoco is open source, so a PR, if done properly, for schema generation would be happily accepted ;)
Finally, although I don't follow NPoco all the closely, I don't think it has support for schema generation from POCOs, and at a guess, it would be due to the same reason listed above.