diff --git a/src/Microsoft.Data.SqlServer/SequentialGuidIdentityGenerator.cs b/src/Microsoft.Data.SqlServer/SequentialGuidIdentityGenerator.cs index f2b6d370d31..3971e98a392 100644 --- a/src/Microsoft.Data.SqlServer/SequentialGuidIdentityGenerator.cs +++ b/src/Microsoft.Data.SqlServer/SequentialGuidIdentityGenerator.cs @@ -13,7 +13,7 @@ public class SequentialGuidIdentityGenerator : IIdentityGenerator static SequentialGuidIdentityGenerator() { - _counter = DateTime.Now.Ticks; + _counter = DateTime.UtcNow.Ticks; } public Task NextAsync() @@ -21,6 +21,11 @@ public Task NextAsync() var guidBytes = Guid.NewGuid().ToByteArray(); var counterBytes = BitConverter.GetBytes(Interlocked.Increment(ref _counter)); + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(counterBytes); + } + guidBytes[08] = counterBytes[1]; guidBytes[09] = counterBytes[0]; guidBytes[10] = counterBytes[7]; diff --git a/test/Microsoft.Data.SqlServer.FunctionalTest/SequentialGuidIdentityGeneratorTest.cs b/test/Microsoft.Data.SqlServer.FunctionalTest/SequentialGuidIdentityGeneratorTest.cs index 4e396aa28ce..dada3c6219e 100644 --- a/test/Microsoft.Data.SqlServer.FunctionalTest/SequentialGuidIdentityGeneratorTest.cs +++ b/test/Microsoft.Data.SqlServer.FunctionalTest/SequentialGuidIdentityGeneratorTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.Data.SqlServer public class SequentialGuidIdentityGeneratorTest { [Fact] - public async Task Can_get_next_values() + public async Task CanGetNextValues() { var sequentialGuidIdentityGenerator = new SequentialGuidIdentityGenerator(); var values = new List();