I add provincesModel
's pr_id
as a foreign Key
to clinicsModel
. So the visual studio display me this error message
Introducing FOREIGN KEY constraint 'FK_dbo.ClinicsModels_dbo.ProvincesModels_pr_id' on table 'ClinicsModels' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
I try to solve the issue by browsing on web to find some solution but I can't get how to solve this. So I remove the foreign key
relation of pr_id
from clinicsModel
and run the project but still visual studio shows me the same error message. I also recreate the ClinicsModel
and try to update database using Update-Database -Verebose Migrations
using package manager console
but still it shows the same error message.
Here's my code:
for ProvinceModel
namespace finalFyp.Models
{
public class ProvincesModel
{
[Key]
public int pr_id { get; set; }
public string pr_name { get; set; }
public ICollection<CitiesModel> cities { get; set; }
}
}
ClinicsModel
:
public class ClinicsModel
{
[Key]
public int clinic_id { get; set; }
public string clinic_name { get; set; }
public string clinic_address { get; set; }
//Forigen Keys
public int ct_id { get; set; }
public CitiesModel city { get; set; }
}
}
As the error occurred when I redirecting to http://localhost:3110/Doctors/index
Here's the snapshot of of error message.
DoctorsModel
:
public class DoctorsModel
{
[Key]
public int d_id { get; set; }
public string d_name { get; set; }
public string contact { get; set; }
public string cnic { get; set; }
public string email { get; set; }
public string gender { get; set; }
//Forigen Key
public ICollection<DocExperiencesModel> experiences { get; set; }
public ICollection<DocSpecialization> specializations { get; set; }
public ICollection<QualificationsModel> qualifications { get; set; }
public ICollection<DoctorProfileModel> profiles { get; set; }
}
For ease of understanding Here's the schema of my database.
Please guide me what I suppose to do? I will be very thankful to him/her.