Utilizing the new `CreateVersion7` API for `ValueGeneratedOnAdd`
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
With the new introduction of `Guid.CreateVersion7(DateTimeOffSet.UtcNow);` in .NET 9 (see: https://github.com/dotnet/runtime/issues/103658), there is a native way to have sortable GUID PK's without any additional 3rd party tools or custom value generators.
This new behavior might be excellent to expose in calls to `ValueGeneratedOnAdd` / `ValueGeneratedOnAddOrUpdate`.
## Alternative
The user could implement something like this (simplified):
```csharp
public class UUIDv7Generator : ValueGenerator
{
protected override object NextValue(EntityEntry entry) => Guid.CreateVersion7(DateTimeOffset.UtcNow);
public override bool GeneratesTemporaryValues { get; }
}
public void Configure(EntityTypeBuilder builder)
{
builder.Property(t => t.Id).HasValueGenerator().ValueGeneratedOnAdd();
```
Contributor guide
Assessment
This issue has not been assessed yet.