KEMBAR78
How to use alternate type "REAL" (JulianDay) for DateTimes in EFcore? · Issue #24714 · dotnet/efcore · GitHub
Skip to content

How to use alternate type "REAL" (JulianDay) for DateTimes in EFcore? #24714

@springy76

Description

@springy76

Microsoft.Data.Sqlite has support for this: https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/types#alternative-types : Using REAL (JulianDay) instead of TEXT (ISO8601 formatted string).

But how do I enable this for EFcore for newly written data? (Reading existing databases already seems to work fine)

I tried
builder.Property("name").HasColumnType("REAL")
and
builder.Property("name").HasConversion<double>() or .HasConversion<float>()

I tried both each other exclusive and in combination:

  • HasColumnType only reflects in create table but uses still TEXT for new data (used SQLite's typeof() function to verify)
  • HasConvertion just fails on creating initial SQL

In contrast in order to use binary blob GUIDs (instead of strings) just works by using .HasColumnType("BLOB").HasConversion<byte[]>().

I fear I have to write a converter which calculates the JulianDay in advance?

[EF 5.0.5 on netcore3.1 and net5]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions