SequentialGuid 2.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SequentialGuid --version 2.2.1
NuGet\Install-Package SequentialGuid -Version 2.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SequentialGuid" Version="2.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SequentialGuid --version 2.2.1
#r "nuget: SequentialGuid, 2.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SequentialGuid as a Cake Addin
#addin nuget:?package=SequentialGuid&version=2.2.1

// Install SequentialGuid as a Cake Tool
#tool nuget:?package=SequentialGuid&version=2.2.1

SequentialGuid

Will generate Sequential Guids based on MongoDB's ObjectId specification. Date & time are encoded into the value so you do not need to store them separately in your database

Define an interface to the signature you like

public interface IIdGenerator
{
    Guid NewId();
}

Define your implementing class which can be transient since the singleton is implemented by the framework

public class SequentialIdGenerator : IIdGenerator
{
    public Guid NewId() => SequentialGuidGenerator.Instance.NewGuid();
}

Wire it up to .NET Core dependency injection in the ConfigureServices method during application startup

public void ConfigureServices(IServiceCollection services)
{
    `services.AddTransient<IIdGenerator, SequentialIdGenerator>();`
}

Finally define a base entity for your application which will contain an id and a timestamp as soon as you initialize it. Note I do not advocate setting a default Id getter this way just illustrating it can be done

public abstract class BaseEntity
{
    public Guid Id { get; set; } = SequentialGuidGenerator.Instance.NewGuid();
    public DateTime? Timestamp => Id.ToDateTime();
    // If you really must have non-UTC time
    public DateTime? LocalTime => Id.ToDateTime()?.ToLocalTime();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on SequentialGuid:

Package Downloads
BR.MicroServices.Utilities

Package Description

SequentialGuid.NodaTime

Provide extension methods to round trip between NodaTime Instant and sequential guid

Loyo.EntityFramework

EntityFrameworkCore UnitOfWork Repositories

Atomiv.Infrastructure.SequentialGuid

Package Description

Optivem.Atomiv.Infrastructure.SequentialGuid

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.5 1,488 3/20/2024
4.0.4 335,831 2/27/2023
4.0.3 48,696 10/25/2022
4.0.2 8,633 10/20/2022
4.0.1 5,207 10/10/2022
4.0.0 3,207 10/5/2022
3.0.1 84,464 2/22/2022
3.0.0 30,748 9/15/2021
2.5.0 250,620 11/18/2020
2.4.2 21,527 7/31/2020
2.4.1 26,766 7/8/2020
2.4.0 176,749 12/13/2017
2.2.1 2,045 10/17/2017
2.2.0 2,064 9/24/2017
1.0.0 5,091 2/17/2014

Moved to .netstandard2.0 so it can be used with .NET Core on Linux & OSX