I've recently come across an EF6 application where the logic is driven heavily by the use of IDs, something I hadn't seen before.
Once an entity is loaded by EF at the DAL, it is mapped to another near-identical POCO object which sits in the Business Logic layer.
Whenever entities are worked with in the Business Logic, the relationships are determined using IDs, for example:
var applesOnTree = forestApples.Where(a => a.TreeID == tree.ID)
This seemed extremely odd to me, whereas before I'd always worked with applications which expressed relationships using objects:
var applesOnTree = tree.Apples;
Is it normal to use generated IDs in the Business Logic like that when using EF?
It feels strange personally. Is it a better practice to never work with IDs except in the DAL layer? Or is this ability considered a useful benefit of EF?
I suppose it's useful in that it allows you to track what has/hasn't been persisted to the DB yet?