This repository is home to the following project. This project is maintained by Jon Davies and licensed under the Apache Licence, Version 2.0.
- [EntityFrameworkCore.SqlServer.NodaTime]
EF Core SqlServer NodaTime will be available on NuGet. Install the project, along with the SQL Server database provider and underlying EF Core packages.
dotnet add package EntityFrameworkCore.SqlServer.NodaTime
Use the --version
option to specify a preview version to install.
The following code demonstrates a simple entity and DbContext
making use of EF Core SQL Server NodaTime.
class MyEntity
{
public int Id { get; set; }
public Instant Instant { get; set; }
public LocalDate LocalDate { get; set; }
public LocalTime LocalTime { get; set; }
public LocalDateTime LocalDateTime { get; set; }
public OffsetDateTime OffsetDateTime { get; set; }
}
class MyContext : DbContext
{
public DbSet<MyEntity> MyEntities { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
@"Server=(LocalDB)\MSSQLLocalDB;Initial Catalog=SqlServerNodaTime",
options => options.UseNodaTime()
);
}
}