Entity Framework -- An item with the same key has already been added
I am having an intermittent error that I am not able to figure out. When
my application is starting up the following line gives me the error stated
in the title.
IList<DataAgentStatus> list = dbContext.DataAgentStatus.ToList();
The "DataAgentStatus" table only has 12 rows in it and the primary key is
a string with unique names in it.
Any thoughts or ideas on where I should look? Most times if I hit
"Continue" the application runs fine.
DataAgentStatus class (NotificationObject is a prism object that
implements INotifyPropertyChanged)
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; }
}
}
Entry on the DbContext class
public DbSet<DataAgentStatus> DataAgentStatus { get; set; }
No comments:
Post a Comment