-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[Cosmos] ISO date time strings are not read back correctly from the database #25656
Comments
@anttikes This appears to be an issue with the underlying Cosmos API or the Cosmos database implementation itself. EF Core simply treats these values as strings; it never attempts to parse them as dates. I would suggest you fil an issue with Cosmos, possibly starting here: https://github.com/Azure/azure-cosmos-dotnet-v3 |
@ajcvickers Thank you for your investigation. I haver reported the issue to the Cosmos SDK repository that you linked. Hopefully they can figure it out. I'll close this issue. If the Cosmos SDK team reports that the bug is in EF Core then I'll re-open it with whatever relevant details they can provide. |
@anttikes You can work around this by calling |
Thanks @AndriySvyryd for the tip. I think our team can afford to wait for the next release where your fix is included. |
Include your code
A sample application which reproduces the various the scenarios is attached to this post. The project attempts to connect to a CosmosDB emulator running on the local computer. The problem scenario has not been tested against an Azure CosmosDB account.
EFCoreISODatesBug.zip
Include provider and version information
EF Core version: 5.0.9
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Database provider version: 5.0.9
Underlying Azure SDK version: 3.12.0
Target framework: .NET 5.0
Operating system: Windows 10 Enterprise (version "10.0.19043 Build 19043")
IDE: Visual Studio 2019 version 16.11.1
CosmosDB Emulator version: 2.14.1.0 (08dca53e)
Operating system time zone settings: "UTC+02:00 Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"
Reproduction steps
Expected result
Since the model uses a plain string as the property's type the expected behavior is that the strings are saved into CosmosDB as-is, and when they are read back they are still exactly the same as before.
Observed behavior
The items are written correctly to the CosmosDB container, and the content of the documents therein corresponds exactly to the expected outcome.
When the items are read back from CosmosDB then the ISODate property is formatted differently, and the time stamp has automatically been adjusted by the UTC offset. On my computer, the adjustment that is done to the time stamp looks incorrect as well:
Output from 'dotnet --info'
The text was updated successfully, but these errors were encountered: