SequentialGuid.EntityFrameworkCore
5.0.7
dotnet add package SequentialGuid.EntityFrameworkCore --version 5.0.7
NuGet\Install-Package SequentialGuid.EntityFrameworkCore -Version 5.0.7
<PackageReference Include="SequentialGuid.EntityFrameworkCore" Version="5.0.7" />
<PackageVersion Include="SequentialGuid.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="SequentialGuid.EntityFrameworkCore" />
paket add SequentialGuid.EntityFrameworkCore --version 5.0.7
#r "nuget: SequentialGuid.EntityFrameworkCore, 5.0.7"
#:package SequentialGuid.EntityFrameworkCore@5.0.7
#addin nuget:?package=SequentialGuid.EntityFrameworkCore&version=5.0.7
#tool nuget:?package=SequentialGuid.EntityFrameworkCore&version=5.0.7
SequentialGuid.EntityFrameworkCore
EF Core value-converter support for the SequentialGuid library. Register once and Entity Framework Core can automatically persist SequentialGuid and SequentialSqlGuid properties as standard Guid database columns.
Install
dotnet add package SequentialGuid.EntityFrameworkCore
Supported Frameworks
| Target | EF Core Version |
|---|---|
| .NET 10 | 10.0.0 |
| .NET 9 | 9.0.0 |
| .NET 8 | 8.0.10+ |
Setup
Register the value converters in your DbContext by overriding ConfigureConventions:
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
{
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
// Registers converters for both SequentialGuid and SequentialSqlGuid
configurationBuilder.AddSequentialGuidValueConverters();
}
}
This single call registers value converters for both SequentialGuid and SequentialSqlGuid so that any entity property of either type is transparently converted to and from Guid when reading/writing to the database.
Entity Model Example
using SequentialGuid;
public class Order
{
// Assigned at construction - no database round-trip needed
public SequentialGuid Id { get; set; } = new();
// Timestamp is always available from the ID itself
public DateTime? CreatedAt => Id.Timestamp;
public string Description { get; set; } = string.Empty;
}
If you are targeting SQL Server and want IDs that sort correctly in uniqueidentifier columns, use SequentialSqlGuid instead:
public class Order
{
public SequentialSqlGuid Id { get; set; } = new();
}
How It Works
Under the hood, SequentialGuidValueConverter<T> (where T : struct, ISequentialGuid<T>) converts:
- To database: extracts the underlying
Guidviavalue.Value - From database: reconstructs the struct via
T.Create(guid), which validates the GUID is a recognized sequential format
This means the database column type remains a standard Guid / uniqueidentifier - no schema changes are needed.
JSON Serialization
If your API returns entities containing SequentialGuid / SequentialSqlGuid properties, register the built-in JSON converters in your Program.cs:
using SequentialGuid.Extensions;
builder.Services.AddControllers()
.AddJsonOptions(o => o.JsonSerializerOptions.AddSequentialGuidConverters());
Further Reading
See the main SequentialGuid README for full documentation on UUID generation, timestamp extraction, and SQL Server byte-order handling.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- SequentialGuid (>= 5.0.7)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.10)
- SequentialGuid (>= 5.0.7)
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- SequentialGuid (>= 5.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.