简体   繁体   English

EF Core 迁移时间戳有错误的时间(区域)

[英]EF Core Migration Timestamp has wrong time(zone)

I have an EF Core Code First Project and use EF Core 3.1.0-preview2.19525.5.我有一个 EF Core Code First 项目并使用 EF Core 3.1.0-preview2.19525.5。 When I create a new migration with Add-Migration , the timestamp is one hour in the past.当我使用Add-Migration创建新迁移时,时间戳是过去一小时。

Example 20191110 1739 16_MickeyMouse.cs is a migration I created today at 18:39示例 20191110 1739 16_MickeyMouse.cs 是我今天18:39创建的迁移

My machine an English Windows 10 device based in Germany and the timezone is configured to UTC+1 (Amsterdam, Berlin, ...)我的机器是位于德国的英语 Windows 10 设备,时区配置为 UTC+1(阿姆斯特丹、柏林……)

Not that this a problem at all, but I am just wondering.这根本不是问题,但我只是想知道。 Where does the timestamp come from?时间戳从何而来? I would expect just the developer's local time.我希望只是开发人员的当地时间。

Not sure, but sounds like the timestamp in the migration class name is the UTC datetime.不确定,但听起来像迁移 class 名称中的时间戳是 UTC 日期时间。

You can verify this by changing your pc's timezone to UTC+2 and create a new migration.您可以通过将电脑的时区更改为 UTC+2 并创建新的迁移来验证这一点。 I expect the timestamp to be 2 hours ahead of that timezone.我希望时间戳比该时区早 2 小时。

The timestamp isn't in UTC is it?时间戳不是UTC吗? That would make sense as it would enable developers in different geographical locations to work on a project without migrations being done in the wrong order because one was done, for example, four hours after a previous migration but in a timezone that would stamp the file as ahead of the previous migration.这将是有道理的,因为它可以让不同地理位置的开发人员在项目上工作,而不会以错误的顺序完成迁移,例如,在上一次迁移后四小时完成迁移,但时区会将文件标记为在之前的迁移之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM