我有一个简单的查询,如下所示:
return await _context.Blog
.Include(x => x.Posts)
.Include(x => x.People)
.ToListAsync();`
运行此命令时,将引发“数据为空”错误。堆栈跟踪开始如下:
at System.Data.SqlTypes.SqlGuid.get_Value()
at Microsoft.Data.SqlClient.SqlDataReader.GetGuid(Int32 i)
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalShapedQueryCompilingExpressionVisitor.IncludeCompilingExpressionVisitor.IncludeCollection[
TEntity,TIncludedEntity](QueryContext queryContext, DbDataReader dbDataReader,
TEntity entity, Func`3 outerKeySelector, Func`3 innerKeySelector, Func`4
innerShaper, INavigation navigation, INavigation inverseNavigation,
Action 2
fixup, Boolean trackingQuery, ResultCoordinator resultCoordinator)
如果删除.includes之一,则查询运行正常。我可以删除任何一个,并且查询有效,因此它似乎与一个特定实体无关。我的dbcontext具有如下定义的关系:
entity.HasOne(e => e.Blog)
.WithMany(b => b.Postenter code heres)
.HasForeignKey(r => r.BlogsID)
.HasConstraintName("FK_Post_Blog");
预览版本是否存在某种类型的错误?