首页 新闻 会员 周边 捐助

ef core 报错:"Nullable object must have a value"

0
悬赏园豆:30 [已解决问题] 解决于 2019-03-24 14:58

运行一个 asp.net core 2.2 项目时 ef core 报错:

System.InvalidOperationException: Nullable object must have a value.
   at lambda_method(Closure , QueryContext , TransparentIdentifier`2 )
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.ProjectionShaper.TypedProjectionShaper`3.Shape(QueryContext queryContext, ValueBuffer& valueBuffer)
   at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
   at System.Linq.AsyncEnumerable.Aggregate_[TSource,TAccumulate,TResult](IAsyncEnumerable`1 source, TAccumulate seed, Func`3 accumulator, Func`2 resultSelector, CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\Aggregate.cs:line 120

请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:30778
提问于:2019-03-24 14:18
< >
分享
最佳答案
1

有个实体属性定义为 int 类型,但数据库查询结果中出现了 NULL 值,将类型改为 int? 解决了

dudu | 高人七级 |园豆:30778 | 2019-03-24 14:57
其他回答(1)
0

感谢提示@dudu

代码小兵的成长 | 园豆:303 (菜鸟二级) | 2019-05-09 09:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册