Skip to content

Commit

Permalink
Migrations: Use invariant calendar for migration IDs
Browse files Browse the repository at this point in the history
Fixes #12978
  • Loading branch information
bricelam committed Mar 18, 2019
1 parent a801679 commit 1788681
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public virtual string GenerateId(string name)
_lastTimestamp = timestamp;
}

return timestamp.ToString(Format) + "_" + name;
return timestamp.ToString(Format, CultureInfo.InvariantCulture) + "_" + name;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Globalization;
using Microsoft.EntityFrameworkCore.TestUtilities.Xunit;
using Xunit;

namespace Microsoft.EntityFrameworkCore.Migrations.Internal
Expand All @@ -26,6 +29,17 @@ public void CreateId_always_increments_timestamp()
Assert.NotEqual(id1, id2);
}

[Fact]
[UseCulture("fa")]
public void CreateId_uses_invariant_calendar()
{
var invariantYear = CultureInfo.InvariantCulture.Calendar.GetYear(DateTime.Today).ToString();

var id = new MigrationsIdGenerator().GenerateId("Zecora");

Assert.StartsWith(invariantYear, id);
}

[Fact]
public void GetName_works()
{
Expand Down

0 comments on commit 1788681

Please sign in to comment.