Hi I created a database using an Entities diagram in visual studio where i added navigation properties. I created it using this tutorial http://geekswithblogs.net/danemorgridge/archive/2009/10/29/using-visual-studio-2010-beta-2-to-do-entity-framework.aspx It looks like this
User Table
IdUser Name IdAccount
1 Ron 2
2 Carl 1
Navigation property: Account (one to one relation)
Account table
IdAccount Amount
1 50
2 30
Navigation property: Account (one to one relation Notice that user1 has account 2 and user2 has account 1
I do a: var user = infoDB.Users.Include("Account");
This displays:
Ron $50
Carl $30
It shows that Ron has $50 which is the amount of account1, which is wrong because Ron has account number 2....
Why isn't this working?
I have come across with this in several tables I have, not necessarily the idUser has to be the IdAccount, this is just an example to illustrate the problem..
Any ideas? I have still been working on this I did the database from scratch and IdAccount IS the foreign key of Account table, but it is doing the same thing...
I'm doing this in an ASP mvc framework it's like the query from the music tutorial, but there it seems to be working fine with Genres.Include("Albums") does it have to do with the fact that it's a one-to-one relationship?