Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration file name date part is generated based on system region settings #12978

Closed
inlineHamed opened this issue Aug 12, 2018 · 3 comments
Closed
Assignees
Labels
breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. poachable type-bug
Milestone

Comments

@inlineHamed
Copy link

inlineHamed commented Aug 12, 2018

When creating new Migration, Migration file name starts with a date part like '20180808120946_MigrationName' .
and this part seems to be used for ordering.
Our problem is if we change our region settings to some calendar other than Georgian (like Persian Calendar) new migration file name are generated based on Persian date that is for example (13970513103708_NewMigrationName) and that breaks the ordering.
In some of my colleagues PCs even after resting the region settings to Georgian new migration names still generates based on Persian Date.

image

image

image

@inlineHamed
Copy link
Author

I did a little investigate to find the cause
It seems that this file (https://github.com/aspnet/EntityFrameworkCore/blob/d59be61006d78d507dea07a9779c3c4103821ca3/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs)
is responsible for generating migration file names and in this method:

public virtual string GenerateId(string name)
        {
            var now = DateTime.UtcNow;
            var timestamp = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            lock (this)
            {
                if (timestamp <= _lastTimestamp)
                {
                    timestamp = _lastTimestamp.AddSeconds(1);
                }

                _lastTimestamp = timestamp;
            }

            return timestamp.ToString(Format) + "_" + name;
}

We see how the time part is generated.
I have created a simple .Net Core Console App to test this function and copy this function into that App and print the result. but even in Systems that we have Persian Migration, this code will print Georgian Date. it's strange ...
so maybe there is a general configuration in the project some where that cause this
hope this help you

@inlineHamed
Copy link
Author

inlineHamed commented Sep 17, 2018

@ajcvickers Can you put this into 2.2.0 as it's getting very confusing for us?

@ajcvickers
Copy link
Member

@hmdhasani There is potential that when we fix this it could break existing ordering for working applications, so we are planning to do this on the next major version since we try to avoid breaking changes in minor versions.

@bricelam bricelam added help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Mar 13, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview4 Apr 15, 2019
@bricelam bricelam added the good first issue This issue should be relatively straightforward to fix. label May 31, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0-preview4, 3.0.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. poachable type-bug
Projects
None yet
Development

No branches or pull requests

3 participants