Thinking about the Entity Framework

time to read 2 min | 300 words

So, a few more things about the Entity Framework that came up today:

  • One thing that worries me more than a little bit is that the Entity Framework has this three layers model, but all the focus is currently focused on 1:~1 (1:1 or nearly so) approach. This means that the interesting aspect of the Entity Framework, radically different models, is the least visited code path.
    At best, this mean that it wouldn't be supported by the designer, at worst, it wouldn't be supported at all. In either case, pain is waiting for the implementors.
  • The Entity Framework doesn't support lazy loading, this means that your code is going to have stuff like: "customer.Orders.Load()" scattered throughout it. Microsoft is saying that they are doing this in purpose, in order to make it explicit when you are going to the database.
    Frankly, I consider this as a cop out for the lazy loading problem. Now Microsoft can blame the developers for this problem. This is something that should be solved by the framework, not shifting the blame elsewhere.
  • This bring me to another issue, the Entity Framework's eager loading facility is a cartesean product nightmare. Trying to load a deep object grap will return a very wide result. NHibernate, on the other hand, has MultiQuery/MultiCriteria, which can be used to load a deep object graph with a single roundtrip, but with multiple result sets, drastically reducing the amount of data that goes on the wire.