I'm trying to accomplish a simple task of creating a database with 2 tables with a 1:* relationship.
In one table (Foos) I have
Id
...
...
In the other (Bars) I have
Id
FooId
...
...
...
I created a Foreign Key Relationship from Bars to Foos with the Foriegn Key Table being Bars pointing to the FooId column, and the Primary Key table being Foos pointing to the Id column.
I then created my ADO.NET Entity data model and it correctly picked up the Foos and Bars tables and the relationship and creates the navigation properties.
Now from within my MVC application I try to get a Foo like this:
var foo = (from f in _db.Foos where f.Id == id select f).FirstOrDefault();
Then I try to access the Bars property of the foo object and get no results. However if I inspect the _db.Bars set I see the Bars with the FooId set to the correct id.
What should I do to troubleshoot why the relationship isn't working? I have looked at many tutorials and the documentation in MSDN for table relationships but nothing is obviously wrong.
I'm trying to use this in a ASP.NET MVC application in case that is relevant.