I am trying to duplicate currentAppointment to appointment. My issue is that currentAppointment has a GUID. When I try to create a new duplicate appointment I get the following error. 'The property 'AppID' is part of the object's key information and cannot be modified. '.
This completely makes sense why I am getting this error and I know I can get around it by going field by field down and match them up (32 fields) but I would like to know if there is a way to give 'appointment' a new guid without going field by field.
Appointment currentAppointment = db.Appointments.Find(id);
Appointment appointment = currentAppointment;
appointment.AppID = Guid.NewGuid(); (where I get the error since I already have a guid from currentAppointment but would like appointment to have a new one.)
appointment.AgentID = 1;
appointment.StatusID = 13;
db.Appointments.Add(appointment);