You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://www.nuget.org/packages/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime/)
3
-
[Version History](#version-history)
4
3
5
-
# EFCore.SqlServer.NodaTime
4
+
# EntityFrameworkCore.SqlServer.NodaTime
6
5
7
6
Adds native support to EntityFrameworkCore for SQL Server for the [NodaTime](https://nodatime.org/) types.
8
7
9
-
When modelling, usage of the following NodaTime types are supported:
10
-
* Instant
11
-
* OffsetDateTime
12
-
* LocalDateTime
13
-
* LocalDate
14
-
* LocalTime
15
-
* Duration (stored as `time` in SQL Server which limits this type to < 24 hours)
16
-
17
-
When querying, standard operators are supported as well as a range of additional mappings from NodaTime properties/function to their SQL Server equivalents.
18
-
19
-
## Unit Tests
20
-
All types and their methods have unit tests written to verify that the SQL is translated as expected. See individual tests for more information.
21
-
22
-
**Note:** To run the unit tests for the first time, you will need to uncomment the lines [here](https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime/blob/017f19d68ac12e0ff2ce3ba34f60f1edd42badfe/src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DatabaseTestFixture.cs#L20-L21). This ensures that the test DB is created locally.
**Note:** Versioning follows the [major.minor] of EF Core so that it is easy to know which version to install. Ie, if you are using EF Core v5.x then you would install v5.x of this package. Build and revision numbers are not guaranteed to follow the same numbers.
31
-
32
-
Then call the `UseNodaTime()` method as part of your SqlServer configuration during the `UseSqlServer` method call:
33
-
```csharp
34
-
usingMicrosoft.EntityFrameworkCore;
35
-
36
-
options.UseSqlServer("your DB Connection",
37
-
x=>x.UseNodaTime());
38
-
```
39
-
40
-
## Reverse Engineering (Scaffolding)
41
-
Support for [reverse engineering](https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli) has been added starting in v5.0.2.
42
-
43
-
The SQL Server types map as follows:
44
-
*`smalldatetime` -> `Instant`
45
-
*`datetime` -> `Instant`
46
-
*`datetime2` -> `Instant`
47
-
*`date` -> `LocalDate`
48
-
*`time` -> `LocalTime`
49
-
*`datetimeoffset` -> `OffsetDateTime`
50
-
51
-
## Additional property / function mappings
52
-
53
-
### DATEADD Support
54
-
The SQL `DATEADD` function is supported for the following types:
55
-
* Instant (extension methods)
56
-
* OffsetDateTime (native and some extension methods)
57
-
* LocalDateTime (native and some extension methods)
58
-
* LocalDate (native and some extension methods)
59
-
* LocalTime (native and some extension methods)
60
-
* Duration (native and some extension methods)
61
-
62
-
**Note**: Please add a using statement in order to use the extension methods:
0 commit comments