I want to copy full information of record to another in EF C#:
List<Cohort> AnYearsCohorts = oDB.Cohorts.Where(x=>x.Year == oCh.Year).ToList();
foreach (Cohort ochort in AnYearsCohorts)
{
Cohort nChort = new Cohort();
nChort = ochort;
nChort.Year = Year;
nChort.ID = 0;
oDB.Cohorts.Add(nChort);
}
oDB.SaveChanges();
But got following error:
{"The property 'ID' is part of the object's key information and cannot be modified. "}