System.ArgumentException: элемент с таким же ключом уже добавлен. Ключ: Эксперт
До недавнего времени все работало нормально, и я не уверен, что изменилось.
< strong>Модель
Код: Выделить всё
public class FacilityQCResult
{
[Key]
public int ID { get; set; }
public Guid? QCID { get; set; }
public string QCSeverity { get; set; }
public string QCType { get; set; }
public string QCShortName { get; set; }
public string Resolution { get; set; }
public string Base { get; set; }
public string FacilityNumber { get; set; }
public string FacilityName { get; set; }
public DateTime? DataEntryComplete { get; set; }
public string TeamAssignment { get; set; }
public string Assessor { get; set; }
public string TripWeek { get; set; }
public string Details { get; set; }
public Guid? FacilityID { get; set; }
}
Код: Выделить всё
public partial class SQLDBContext : DbContext
{
public SQLDBContext()
{
}
public SQLDBContext(DbContextOptions options)
: base(options)
{
}
public virtual DbSet FacilityQCResults { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(entity =>
{
entity.ToTable("FacilityQCResult");
entity.HasKey(e => e.ID);
entity.Property(e => e.DataEntryComplete)
.HasColumnName("Data_Entry_Complete")
.HasColumnType("datetime");
entity.Property(e => e.TeamAssignment)
.HasColumnName("Team_Assignment")
.HasMaxLength(100)
.IsUnicode(false);
entity.Property(e => e.TripWeek)
.HasColumnName("Trip_Week")
.HasMaxLength(10)
.IsUnicode(false);
});
}
}
[img]https://i. sstatic.net/lbgG8.png[/img]
Выдает ошибку, когда доходит до следующей строки:
Код: Выделить всё
var result = await context.FacilityQCResults.FromSqlRaw(" exec [dbo].[pr_ExecuteFacilityQCRules]").ToListAsync();
Подробнее здесь: https://stackoverflow.com/questions/632 ... been-added