Have many tables where I have GUID as primary key in each table. I want to create a copy with new Guid from the original record in all tables.
While doing this, I am getting an error The property 'Guid' is part of the object's key information and cannot be modified in line# 9.
1. var project = context.Projects.FirstOrDefault(x => x.Guid == projectGuid); // existing record
2. if (project != null)
3. {
4. project.Guid = Guid.NewGuid(); // Setting newguid
5. //....... need same values from rest of the columns
6.
7. project.CreatedBy = userAccountGuid;
8. project.CreatedDate = DateTime.Now;
9. context.Projects.Add(project); // Adding a new record
10.
11. }