Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Foreign key tables not listed after adding Entity Data Model

$
0
0

I have various foreign key tables in the database.   These tables contain the relationship between two other tables.   For example the Job_Locations table holds the JobID which is the primary key of the Jobs table  and the LocationID which is the primary key of the Locations table.  None of these foreign key tables is listed in my models.

I can see in the edmx where it shows Jobs in the Navigation Properties of Location and Locations in the Navigation Properties of Job.  

I figured out how to get a record count to be able to tell when the position is posted at a single location by using this

var count = db.Jobs.Where(a => a.JobID == JobID).SelectMany(a => a.Locations).Count();

Now I need to find the LocationID when there is only a single location  but am not sure how to do it  

 


Viewing all articles
Browse latest Browse all 1698

Trending Articles