Skip to content

jpd30/EntityFrameworkCore.SqlServer.NodaTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Repository

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]

EntityFrameworkCore.SqlServer.NodaTime

Installation

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.

Usage

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()
        );
    }
}

About

NodaTime extension for the Microsoft SQL Server database provider for Entity Framework Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages