Entity framework core ef core plus:ArgumentNullException:值不能为null。参数名称:属性

Entity framework core ef core plus:ArgumentNullException:值不能为null。参数名称:属性,entity-framework-core,entity-framework-plus,Entity Framework Core,Entity Framework Plus,使用ef core plus,我尝试更新模型上的一组行: await _context.Set<Critique>() .Include(c => c.User) .Where(c => c.Closed && c.User.Id == user.Id) .UpdateAsync(c => new Critique() { User = deletedUser }); wait

使用ef core plus,我尝试更新模型上的一组行:

await _context.Set<Critique>()
            .Include(c => c.User)
            .Where(c => c.Closed && c.User.Id == user.Id)
            .UpdateAsync(c => new Critique() { User = deletedUser });
wait_context.Set()
.Include(c=>c.User)
.Where(c=>c.Closed&&c.User.Id==User.Id)
.UpdateAsync(c=>newcommission(){User=deletedUser});
这里我得到了以下例外:

ArgumentNullException:值不能为null。 参数名称:属性 Check.cs第21行中的Npgsql.EntityFrameworkCore.PostgreSQL.Utilities.Check.NotNull(T值,字符串参数名称)

TargetInvocationException:调用的目标已引发异常。 System.RuntimeMethodHandle.InvokeMethod(对象目标,对象[]参数,签名符号,bool构造函数,bool wrapException

当我用efcore加载数据时,它加载我期望的1行

var test = await _context.Set<Critique>()
            .Where(c => c.Closed && c.User.Id == user.Id)
            .ToArrayAsync();
var test=await\u context.Set()
.Where(c=>c.Closed&&c.User.Id==User.Id)
.ToArrayAsync();
数据库模型没什么特别的,但是太大了,不能在这里发布。我正在广泛使用[Required],并且有大量的一对多关系

(顺便说一句,user.Id不为null且不可用,deletedUser在代码和数据库中都可用。)

这个错误应该如何解释?我做错了什么


感谢您的帮助!

我们的库可以更新值,但目前无法使用导航属性更新值

这不管用

.UpdateAsync(c => new Critique() { User = deletedUser });
但如果你有财产的话,这就行了

.UpdateAsync(c => new Critique() { UserID = deletedUserID });

另外,没有必要添加
.Include(c=>c.User)
,因为您无法检索此信息。

感谢您花时间回答!是的,包含是一种绝望的行为。好的,感谢您的澄清!