Is there a standard option to generate UUID version 7? (Guid)
Hello,
.NET provides a way to generate UUID v4 with
Guid.NewGuid()
, but this cannot be used as a PK for tables. In Postgres newer UUID versions can be used as primary keys, as they are sortable and because of that there is no index fragmentation.
Is there a standard library that is used for generating UUID 7? It is a bit odd there is no built in way to do this.4 Replies
are you looking specifically for a database scenario? b/c usually you'd want the database to do that work
but to answer your question directly, afaik no
I use https://github.com/medo64/Medo.Uuid7 - it has efcore integration to take care of all the conversion stuff i believe
GitHub
GitHub - medo64/Medo.Uuid7: This is a C# implementation of UUIDv7 g...
This is a C# implementation of UUIDv7 generation algorithm. - GitHub - medo64/Medo.Uuid7: This is a C# implementation of UUIDv7 generation algorithm.
it's not available in the BCL yet and probably won't be for awhile if ever just to avoid confusion over multiple potentially conflicting UUID types
Thanks, after doing a bit of research, it turns out that the UUID 7 is still in development: https://uuid.ramsey.dev/en/stable/rfc4122/version7.html
It will take time until this is standardized
The speed of the generations is not much worse compared to the
Guid.NewGuid()
I will go with the Medo.Uuid7, thank you for the suggestion
Isn't it a bit concerning that it allocates 40B memory?