The Agony of EF
We’ve been working with EF v1 (.NET 3.5) for a little while now, using it sparingly when creating new code requiring CRUD functionality, and refactoring older code with similar characteristics. You may recall, from an earlier post, that our approach was to use EF to create a data-layer to replace the Datasets, Datatables and Datareaders we currently use with type-safe rich Entity Objects. It was not and is not our intention to replace our existing business objects with EF. To this end, we employed a repository pattern that serves up ‘detached’ EF objects which are then used to hydrate and persist our business objects. All too easy Initially, the results were very positive. With some of the simpler cases we started with (mapping tables with few or no relationships) an immediate benefit was obvious. We could replace the SELECT stored procedures with equivalent Linq-to-Entities statements, and remove entirely the INSERT, UPDATE and DELETE stored procedures in favor of EF persi