1

If EF model(s) are contained in a separate assembly and referenced/used by the Data Access Layer for all DB operations, is it acceptable to also reference that same assembly with EF model(s) from the Business Intelligence layer in order to simplify the data transfer from DAL to BI layer?

This would allow for elimination of DTO objects or in my case Tuples I use to transport the data from DAL to BI since the DAL could just return EF objects that BI would already "know" about. The question is if this would be frowned upon from the architecture stand point as something that is going against the separation of concerns or some other rule of good software design?

Dean Kuga
  • 11,878
  • 8
  • 54
  • 108

1 Answers1

1

This is why I don't like EF. In order to hide the fact you're using a DB, you have to hide the fact that EF is generating all these nice lovely classes for you by making new ones.

Since EF classes have navigable relations, and those relations are only viable while the entities are attached to a context, you cannot, for example, shoot them across the wire to an API client.

Well, you could, but they would be annoyed whenever you fail to, for example, include related records for a Get call.

Personally, I'd leave the leaky abstraction behind. If not completely (cough dapper cough) then hide your shame in the DL.

  • Of course this is completely untrue. – Federico Berasategui Oct 18 '13 at 19:48
  • @HighCore: Are you saying that navigation properties work disconnected across the wire? Or was that part true, just not the rest? Do you claim that EF isn't utterly leaky? Code first may be the closest EF comes to not being, I'll grant that. –  Oct 18 '13 at 20:05
  • learn to use the platform properly before you complain about it. If you disable lazy loading and proxy creation you can perfectly send stuff via WCF or the like. Yes, you have to `.Include()` stuff, but that's perfectly acceptable, IMO. – Federico Berasategui Oct 18 '13 at 20:12
  • @HighCore: Acceptable to you, not to me. Nor to anyone using the API who has to hope that the right relations are included. I've used it, properly, thanks. It's a leaky abstraction and isn't worth the effort. We can disagree without you calling me ignorant. Now go plug your leaks. –  Oct 20 '13 at 20:08