Support arbitrary primary key fields

Primary key fields are not always called `id`.