I am using role membership web application. I create a custom role provider and membership provider. MY registration page works perfectly. I collect all the necessary information from registration. I log on to the back office and assign user to the proper role.
My tables are user, roles, userinroles, doctors, patients, med, behavior,and reviewers.
userinrole has a fk to user and roles
reviewer has fk to user and userinroles
doctors has fk to user, userinroles and reviewers
patients has fk to doctors
medical, behavior, assessment, and medication has fk to patients
At this moment we only have one reviewer so fk into be assign all doctors.
I need to know how make this happen and make sure that when a doctors fill out the patient form it insert the doctor that is log on id into the patients fk for doctors and all the patients fk for were needed.
I have tried this but getting error.
private entities db = new entities();
db.AddToPatients(patients);
db.AddToMedical(medical);
and so on.
db.SaveChanges();
I
getting error message
The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Patients_Doctors\". The conflict occurred in database \"db\", table \"dbo.Doctors\", column 'DoctorsId'.\r\nThe statement has been terminated."}
I believe I understand that it is trying to create a new record for the doctors but the id already exist. How do I stop this.