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
Note that like DateTime.Now this must not be evaluatable (i.e. always evaluated at the server), but the current plugin model doesn't allow adding stuff to NpgsqlEvaluatableExpressionFilter.
i had prepared this text to report my problem, but my problem looks related to this.
NodaTime.Instant as shadow property HasData problem vs no problem in DbSet.Add
In the attached minimal code example (it's a zip of a minimal VS2017 solution), my model MyEntity has a "Created" shadow property of type NodaTime.Instant.
When I try to seed data for MyEntity using HasData, I encounter a problem (stack trace is below).
F:\vs2017play\NodatimeExpt\App.Data>dotnet ef migrations add init --startup-project ..\StartupConsoleApp
System.InvalidOperationException: The current CSharpHelper cannot scaffold literals of type 'NodaTime.Instant'. Configure your services to use one that can.
at Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper.UnknownLiteral(Object value)
at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper.Literal(IReadOnlyList`1 values, Boolean vertical)
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(InsertDataOperation operation, IndentedStringBuilder builder)
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(String builderName, IReadOnlyList`1 operations, IndentedStringBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGenerator.GenerateMigration(String migrationNamespace, String migrationName, IReadOnlyList`1 upOperations, IReadOnlyList`1 downOperations)
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The current CSharpHelper cannot scaffold literals of type 'NodaTime.Instant'. Configure your services to use one that can.
@githubfanster no, this is not related to your problem. This issue is about translating a NodaTime function call to SQL when sending queries, not when inserting data (the update/insert pipeline is very different from the query pipeline).
It appears that you simply forgot to include UseNodaTime() in your model as indicated in the docs.
If you're still having trouble, please open a new issue rather than posting here again.
Activity
roji commentedon Aug 8, 2018
@austindrenski this seems like a pretty important missing feature, any chance you want to take a stab at it? I'm hoping it wouldn't be too hard.
austindrenski commentedon Aug 8, 2018
@roji Sure, I can take a look at it this weekend.
githubfanster commentedon Aug 8, 2018
I wonder if this is the problem I'm encountering.
i had prepared this text to report my problem, but my problem looks related to this.
NodaTime.Instant as shadow property HasData problem vs no problem in DbSet.Add
In the attached minimal code example (it's a zip of a minimal VS2017 solution), my model MyEntity has a "Created" shadow property of type NodaTime.Instant.
When I try to seed data for MyEntity using HasData, I encounter a problem (stack trace is below).
This code produces an exception:
The stack trace is:
BUT THIS TEST CODE DOES NOT:
Any idea what might be happening? Am I doing something wrong?
Thanks for helping!
NodatimeExpt.zip
roji commentedon Aug 8, 2018
@githubfanster no, this is not related to your problem. This issue is about translating a NodaTime function call to SQL when sending queries, not when inserting data (the update/insert pipeline is very different from the query pipeline).
It appears that you simply forgot to include
UseNodaTime()in your model as indicated in the docs.If you're still having trouble, please open a new issue rather than posting here again.
austindrenski commentedon Aug 9, 2018
Merged in #577.