The current CSharpHelper cannot scaffold literals of type 'NodaTime.OffsetTime'. Configure your services to use one that can.
See original GitHub issueHaving issues with time. Like so few other people I assumed Timestamp with time zone
stored time zone information. Trying to correct my mistake by switching to NodaTime now. I switched all my DateTimeOffset’s to Instant, and my DateTime?'s to LocalDate?'s. Creating a migration to make the change wasn’t working so I just regex’ed my ModelSnapshot, Migrations and Designer files to use the appropriate type. That worked fine but running into problems trying to make a Time with time zone
column so I can separately store the time of day information in Postgres. Whenever I try to scaffold a migration I get the error
The current CSharpHelper cannot scaffold literals of type ‘NodaTime.OffsetTime’. Configure your services to use one that can.
Here is the model I am trying to make the migration for (with several properties omitted).
public class Event
{
public Instant Start { get; set; }
public OffsetTime StartTimeOfDay { get; set; }
public Instant? End { get; set; }
public OffsetTime? EndTimeOfDay { get; set; }
}
Saw something about it possibly being project references so here are my refs. Tried to play around with them but was unsuccessful.
<ItemGroup>
<PackageReference Include="AutoMapper" Version="7.0.1" />
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="2.1.1" />
</ItemGroup>
Also tried switching to DateTimeOffset and using [Column(TypeName = "time with time zone")]
and the migration worked but got a TimeTzHandler cannot convert to DateTimeOffset error when trying to save any entities.
I did try making a fresh solution and context and it did successfully create an initial migration with the above model even when the dbcontext was in a separate solution
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
For the root cause here see #575 (which is actually https://github.com/aspnet/EntityFrameworkCore/issues/8741).
@WarrenFerrell Glad to hear it worked out. Please do let us know if you end up finding the root cause, happy to reopen at that time.