Extract primary key value generation into a separate method.

This allows users the ability to override pk generation if they don't
want to use the type system.