I have the given EF entity.
[Key]
[Column("ACTIVITY.ID", Order = 0)]
public string ActivityId { get; set; }
[Key]
[Column("STATISTIC.SECTION", Order = 1)]
public string StatisticSection { get; set; }
[Key]
[Column("STATISTIC.NAME", Order = 2)]
public string StatisticName { get; set; }
[Key]
[Column("LAP.ID", Order = 3)]
public string LapId { get; set; }
[Column("STATISTIC.TYPE")]
public string StatisticType { get; set; }
[Column("STATISTIC.VALUE")]
public string StatisticValue { get; set; }
[Column("STATISTIC.UNIT")]
public string StatisticUnit { get; set; }
and when doing an insert operation using the method bellow:
public bool Add(ICollection<RefLapStatistic> entities)
{
return HandleInsert(() =>
{
using (var context = new ReportingRefDataContext(DataSource))
{
var activities = entities.Select(x => x.ActivityId).Distinct();
var entitiesToDelete = context.LapStatistics
.Where(x => activities.Any(y => x.ActivityId.Equals(y, System.StringComparison.OrdinalIgnoreCase)));
context.LapStatistics.RemoveRange(entitiesToDelete);
entities.ToList().ForEach(x => context.LapStatistics.Add(Mapper.Map< RefLapStatisticEntity>(x)));
return context.SaveChanges() > 0;
}
});
}
I get the following error when executing the line bellow:
var entitiesToDelete = context.LapStatistics
.Where(x => activities.Any(y => x.ActivityId.Equals(y, System.StringComparison.OrdinalIgnoreCase)));
Unable to determine composite primary key ordering for type
I have no idea why this is happening, can't see any issues with the mapping and the exception is being raised even before the Save method. This issue has nothing to do with missing the Ordering attribute has I've have that defined.