views:

20

answers:

0

hi i have problrm with this

ihave class with name patient that each patient have patintcase and insuranseinfo

when i try to add patient i recive this error

(The EntityKey property can only be set when the current value of the property is nul)

and here is my code:

  public Patient(Doctor doctorname, string n, string f, string codemeli, string datebirth, bool gender, bool material, string age, bool group,PatientCase pc,Address a,contactdetail condetail)
  {
      this.Doctor = doctorname;
      doctorname.patient.add(this)
      this.Firstname = n;
      this.lastname = n;
      this.internationalcode = codemeli;
      this.dateofbirth = datebirth;
      this.gender = gender;
      this.materialstatus = material;
      if(age!="")
      this.age = int.Parse(age);
      this.group = group;
      this.PatientCase = pc;
      this.adres = a;
      this.contac = condetail;

  }

and save method

    db = new DentalContainer(DbAccess.Get_EntityConstring());
       db.tblPerson.AddObject(this);
       db.SaveChanges();

please help me