Click here to Skip to main content
15,896,526 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

Some examples here
Entity Framework Performance[^]
 
Share this answer
 
Comments
postonoh 15-Mar-12 14:45pm    
figure out how to grab the user that is log on. now I need insert that doctors pk into the fk of patients
postonoh 15-Mar-12 16:12pm    
Thanks,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900