I have 2 tables in a SQL database 'tbl_Job' and 'tbl_JobType', I added a FK relationship to tbl_Job pointing to tbl_JobType but when I reverse engineer using Entoty Framework 6 code first it reads as
this.HasRequired(t => t.JobType)
.WithMany(t => t.Jobs)
.HasForeignKey(d => d.JobTypeId);
And it has completely through me, I appreciate SQL doesn't understand 1 to 1 relationships and neither does EF6 but i wasn't expecting the foreign key relationship to create a navigation property pointing in the wrong direction.
Does anyone have a suggestion on what the best way to use a lookup table in SQL with a relationship or constraint with an example?
Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire