我有一个间歇性的错误,我无法弄明白。当我的应用程序启动时,以下行给出了标题中声明的错误。
IList<DataAgentStatus> list = dbContext.DataAgentStatus.ToList();
“DataAgentStatus”表中只有12行,主键是一个包含唯一名称的字符串。
关于我应该注意的任何想法或想法?大多数情况下,如果我点击“继续”,应用程序运行正常。
DataAgentStatus类(NotificationObject是一个实现INotifyPropertyChanged的prism对象)
public class DataAgentStatus : NotificationObject
{
[Key]
public string DataAgentName { get; set; }
public DateTime? LastAccessDate { get; set; }
public bool ErrorState { get; set; }
public string ErrorMessage { get; set; }
public int? Quantity { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? LastModifiedDate { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
}
}
DbContext类的输入
public DbSet<DataAgentStatus> DataAgentStatus { get; set; }
从错误中调用堆栈。
at System.Collections.Generic.Dictionary
2.Insert(TKey key, TValue value, Boolean add) at System.Data.Objects.ObjectStateManager.AddEntityEntryToDictionary(EntityEntry entry, EntityState state) at System.Data.Objects.ObjectStateManager.AddEntry(IEntityWrapper wrappedObject, EntityKey passedKey, EntitySet entitySet, String argumentName, Boolean isAdded) at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func
2 constructEntityDelegate,EntityKey entityKey,EntitySet entitySet) 在lambda_method(Closure,Shaper) 在System.Data.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper shaper) at System.Data.Common.Internal.Materialization.Shaper
1.SimpleEnumerator.MoveNext() 在System.Collections.Generic.List1..ctor(IEnumerable
1个集合) 在System.Linq.Enumerable.ToList [TSource](IEnumerable`1 source) at c:\ Projects \ WPF中的WPF.Data.Models.DataAgentStatus.List(DataBroker dbContext) - Trunk \ src \ Components \ Framework.WPF \ Data \ Models \ DataAgentStatus.cs:第88行 在C:\ Projects \ WPF中的Framework.WPF.Data.Models.DataAgentStatus.ReloadObjects(DataBroker dbContext) - Trunk \ src \ Components \ Framework.WPF \ Data \ Models \ DataAgentStatus.cs:第101行 位于c:\ Projects \ WPF中的WPF.Data.Models.DataAgentStatus.LoadByType(DataBroker dbContext,String statusName,Boolean forceReload) - Trunk \ src \ Components \ Framework.WPF \ Data \ Models \ DataAgentStatus.cs:第73行 在C:\ Projects \ WPF中的Framework.WPF.Data.Models.DataAgentStatus.LoadByType(DataBroker dbContext,String statusName) - Trunk \ src \ Components \ Framework.WPF \ Data \ Models \ DataAgentStatus.cs:第66行 位于c:\ Projects \ WPF中的Base.Data.Handlers.ReferenceDataHandler.GetUserWebLinks(ReceivingDatabroker dbContext) - Trunk \ src \ Receiving \ Receiving.Base \ Data \ Handlers \ ReferenceDataHandler.cs:第40行 位于c:\ Projects \ WPF中的Base.Data.Agents.UserWebLinkDataAgent.UserLinks(ReceivingDatabroker dbContext) - Trunk \ src \ Receiving \ Receiving.Base \ Data \ Agents \ UserWebLinkDataAgent.cs:第41行 at Receiving.Base.Data.Handlers.LoginHandler.timmy_Elapsed(Object sender,ElapsedEventArgs e)在c:\ Projects \ WPF中 - Trunk \ src \ Receiving \ Receiving.Base \ Data \ Handlers \ LoginHandler.cs:第144行 在System.Timers.Timer.MyTimerCallback(对象状态)