C# 我如何才能找到我';调试时我丢失了什么?

C# 我如何才能找到我';调试时我丢失了什么?,c#,.net,entity-framework,debugging,argumentnullexception,C#,.net,Entity Framework,Debugging,Argumentnullexception,我尝试使用以下代码向dbcontext异步添加一些内容: var entry=await\u context.AddAsync(person) 但是,我得到以下例外情况: System.ArgumentNullException:值不能为null。参数名称:key 在System.ThrowHelper.ThrowArgumentNullException处(参数异常) at System.Collections.Generic.Dictionary`2.FindEntry(TKey) 在Sys

我尝试使用以下代码向dbcontext异步添加一些内容:

var entry=await\u context.AddAsync(person)

但是,我得到以下例外情况:

System.ArgumentNullException:值不能为null。参数名称:key

在System.ThrowHelper.ThrowArgumentNullException处(参数异常)

at System.Collections.Generic.Dictionary`2.FindEntry(TKey)

在System.Collections.Generic.Dictionary`2.TryGetValue(TKey、TValue和value)

位于Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.TryGetEntry(对象实体,entityType entityType)

位于Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.InitialFixup(InternalEntityEntry条目,ISet`1 handledForeignKeys,布尔fromQuery)

位于Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.StateChanged(InternalEntityEntry条目、EntityState oldState、布尔fromQuery)

位于Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryNotifier.StateChanged(InternalEntityEntry条目、EntityState oldState、布尔fromQuery)

位于Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.FireStateChanged(EntityState oldState)

在Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.d_u18.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.d_u6.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.d_u1`1.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在Microsoft.EntityFrameworkCore.DbContext.d_u64.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在Microsoft.EntityFrameworkCore.DbContext.d_u66`1.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中

在PersonRepository.d_uu4.MoveNext()中

---来自引发异常的上一个位置的堆栈结束跟踪---

在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中

在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中

在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中

在PersonController.cs中的PersonController.d_u3.MoveNext()处:第63行

在阅读这些语句时,我无法找到可能缺少的值。在调试过程中,我不知道要寻找什么。
如何查找调试时缺少的值?

为您试图添加的人定义的ID似乎为空。如果未配置数据库ID生成,则在将此人添加到上下文之前,需要为其提供ID。

有关为模型定义键列(如主键列)的更多信息,请参阅。