Take the 2-minute tour ×  One requirement is that when
persisting my C# objects to the database I must decide the
database ID (surrogate primary key) in code.  Second requirement
is that the database type for the key must be int or char(x)...
so no uniqueidentifier or binary(16) or the like.  These are
unchangeable requirements.  What would be the best way to go
about handling this?  One idea is the base64 encoded GUIDs
looking like "XSiZtdXcKU68QWe7N96Dig". These are easily created
in code and are to me acceptable in URLs if necessary. But will
it be too expensive regarding performance (indexing, size)
having all primary and foreign keys be char(22)? Off hand I
really like this idea.  Another idea would be to create a code
version of a database sequence creating incremented integers for
me. But I don't know if this is plausible and would need some
guidance to secure the reliability. The sequencer must know har
far it has come and what about threads that I don't control etc.
I imagine that no table involved