UUID v7 coming in .NET 9
For those that didn’t know, you can create Guids in different ways (algorithms).
System.Guid supports UUID v4 out-of-the-box, the most used version.
UUID v7 is now added, which creates Guids based on the current time. This means Guids can be sorted, which is more index friendly for databases (=faster).
SQL Server already has the alternative NEWSEQUENTIALID() for ages to fix the sorting problem in the database.
But now .NET 9 will natively support UUID v7, complete with timestamps!
You can create Guids as UUID v4 using the new CreateVersion7() method:
πππβπππππ·β=βπΆπππ.π²ππππππ πππππππ½();
πππβπππππ·β=βπΆπππ.π²ππππππ πππππππ½(π³ππππππππΎπππππ.ππππ½ππ );
Now you can created sorted Guids in .NET!