Skip to content

Commit db3e15e

Browse files
authored
Document MDS breaking changes from efcore#36229. (#5056)
1 parent 2a99d62 commit db3e15e

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ This page documents API and behavior changes that have the potential to break ex
1717

1818
## Summary
1919

20+
> [!NOTE]
21+
> If you are using Microsoft.Data.Sqlite, please see the [separate section below on Microsoft.Data.Sqlite breaking changes](#MDS-breaking-changes).
22+
2023
| **Breaking change** | **Impact** |
2124
|:----------------------------------------------------------------------------------------------------------|------------|
2225
| [ExecuteUpdateAsync now accepts a regular, non-expression lambda](#ExecuteUpdateAsync-lambda) | Low |
@@ -83,3 +86,101 @@ await context.Blogs.ExecuteUpdateAsync(s =>
8386
}
8487
});
8588
```
89+
90+
<a name="MDS-breaking-changes"></a>
91+
92+
## Microsoft.Data.Sqlite breaking changes
93+
94+
### Summary
95+
96+
| **Breaking change** | **Impact** |
97+
|:----------------------------------------------------------------------------------------------------------|------------|
98+
| [Using GetDateTimeOffset without an offset now assumes UTC](#DateTimeOffset-read) | High |
99+
| [Writing DateTimeOffset into REAL column now writes in UTC](#DateTimeOffset-write) | High |
100+
| [Using GetDateTime with an offset now returns value in UTC](#DateTime-read) | High |
101+
102+
### High-impact changes
103+
104+
<a name="DateTimeOffset-read"></a>
105+
106+
#### Using GetDateTimeOffset without an offset now assumes UTC
107+
108+
[Tracking Issue #36195](https://github.com/dotnet/efcore/issues/36195)
109+
110+
##### Old behavior
111+
112+
Previously, when using `GetDateTimeOffset` on a textual timestamp that did not have an offset (e.g., `2014-04-15 10:47:16`), Microsoft.Data.Sqlite would assume the value was in the local time zone. I.e. the value was parsed as `2014-04-15 10:47:16+02:00` (assuming local time zone was UTC+2).
113+
114+
##### New behavior
115+
116+
Starting with Microsoft.Data.Sqlite 10.0, when using `GetDateTimeOffset` on a textual timestamp that does not have an offset, Microsoft.Data.Sqlite will assume the value is in UTC.
117+
118+
##### Why
119+
120+
Is is to align with SQLite's behavior where timestamps without an offset are treated as UTC.
121+
122+
##### Mitigations
123+
124+
Code should be adjusted accordingly.
125+
126+
As a last/temporary resort, you can revert to previous behavior by setting `Microsoft.Data.Sqlite.Pre10TimeZoneHandling` AppContext switch to `true`, see [AppContext for library consumers](/dotnet/api/system.appcontext#ForConsumers) for more details.
127+
128+
```C#
129+
AppContext.SetSwitch("Microsoft.Data.Sqlite.Pre10TimeZoneHandling", isEnabled: true);
130+
```
131+
132+
<a name="DateTimeOffset-write"></a>
133+
134+
#### Writing DateTimeOffset into REAL column now writes in UTC
135+
136+
[Tracking Issue #36195](https://github.com/dotnet/efcore/issues/36195)
137+
138+
##### Old behavior
139+
140+
Previously, when writing a `DateTimeOffset` value into a REAL column, Microsoft.Data.Sqlite would write the value without taking the offset into account.
141+
142+
##### New behavior
143+
144+
Starting with Microsoft.Data.Sqlite 10.0, when writing a `DateTimeOffset` value into a REAL column, Microsoft.Data.Sqlite will convert the value to UTC before doing the conversions and writing it.
145+
146+
##### Why
147+
148+
The value written was incorrect, not aligning with SQLite's behavior where REAL timestamps are asummed to be UTC.
149+
150+
##### Mitigations
151+
152+
Code should be adjusted accordingly.
153+
154+
As a last/temporary resort, you can revert to previous behavior by setting `Microsoft.Data.Sqlite.Pre10TimeZoneHandling` AppContext switch to `true`, see [AppContext for library consumers](/dotnet/api/system.appcontext#ForConsumers) for more details.
155+
156+
```C#
157+
AppContext.SetSwitch("Microsoft.Data.Sqlite.Pre10TimeZoneHandling", isEnabled: true);
158+
```
159+
160+
<a name="DateTime-read"></a>
161+
162+
#### Using GetDateTime with an offset now returns value in UTC
163+
164+
[Tracking Issue #36195](https://github.com/dotnet/efcore/issues/36195)
165+
166+
##### Old behavior
167+
168+
Previously, when using `GetDateTime` on a textual timestamp that had an offset (e.g., `2014-04-15 10:47:16+02:00`), Microsoft.Data.Sqlite would return the value with `DateTimeKind.Local` (even if the offset was not local). The time was parsed correctly taking the offset into account.
169+
170+
##### New behavior
171+
172+
Starting with Microsoft.Data.Sqlite 10.0, when using `GetDateTime` on a textual timestamp that has an offset, Microsoft.Data.Sqlite will convert the value to UTC and return it with `DateTimeKind.Utc`.
173+
174+
##### Why
175+
176+
Even though the time was parsed correctly it was dependent on the machine-configured local time zone, which could lead to unexpected results.
177+
178+
##### Mitigations
179+
180+
Code should be adjusted accordingly.
181+
182+
As a last/temporary resort, you can revert to previous behavior by setting `Microsoft.Data.Sqlite.Pre10TimeZoneHandling` AppContext switch to `true`, see [AppContext for library consumers](/dotnet/api/system.appcontext#ForConsumers) for more details.
183+
184+
```C#
185+
AppContext.SetSwitch("Microsoft.Data.Sqlite.Pre10TimeZoneHandling", isEnabled: true);
186+
```

0 commit comments

Comments
 (0)