Choosing between UUID v4, time-ordered UUID v7, and ULID for database keys
Traditional UUID v4 (`Guid.NewGuid()`) values are completely random, which causes B-tree index fragmentation when used as primary keys in relational databases. UUID v7 (standardized in RFC 9562 and built into .NET via `Guid.CreateVersion7()`) and ULIDs prefix a 48-bit millisecond timestamp before cryptographically random bits—making every generated ID monotonically increasing and database-index friendly.
Frequently Asked Questions (FAQ) & Official Sources
How are these UUIDs and ULIDs generated?
All identifiers are generated locally in your browser using .NET's cryptographic random number generator (`RandomNumberGenerator` and `Guid.CreateVersion7`).
What is the difference between UUID v4, UUID v7, and a C# Guid?
UUID v4 uses 122 random bits, which is great when you do not want to expose creation timestamps, though random ordering can fragment B-tree database indexes. UUID v7 (RFC 9562) starts with a 48-bit millisecond Unix timestamp followed by random bits, so new IDs sort chronologically and stay index-friendly. A C# `Guid` (`System.Guid`) is .NET's 128-bit UUID type: `Guid.NewGuid()` produces a UUID v4, `Guid.CreateVersion7()` produces a UUID v7, and the hyphenated string representation matches the UUID standard.