Hi there,
It's an Object Orientation versus a relational database approach that made me prefer one over the other:
I think this feels much more natural:
than this:
if you look at it from an Object Orientation perspective. In an OO world, a Picture has a PhotoAlbum property that refers to the album it belongs to. The fact it needs stuff like Ids to create the relation in the database is a side issue ;-), let alone the fact it needs a foreign key property called PhotoAlbumId which is merely there for optimization.
In earlier versions of EF, a Picture wouldn't even have a PhotoAlbumId property and you had to do some weird stuff to associate them (not query them as in your example). In EF4, the foreign property was added to make assigning one object to another easier. E.g.:
Code:
myPicture.PhotoAlbumId = 3;
rather than:
Code:
myPicture.PhotoAlbum = context.Albums.Where(p => p.Id == 3).First();
The inclusion of the foreign key property is done to optimize performance and make updates easier.
But, both solutions work fine. So it's perfectly OK to use PhotoAlbumId if that feels more natural to you.
Hope this helps.
Cheers,
Imar