In a previous post I explained how the Entity Framework supported custom construction of entity objects in Orcas beta 1 and before. Unfortunately, the whole mechanism was way too complex and brittle. So, we went back to the drawing board (or the whiteboard as the case may be) and gave more thought to what we were really trying to accomplish. At that point someone, Pablo Castro I think, pointed out that if a class has no constructors the CLR will automatically supply a default constructor which takes no parameters. Further, this default constructor is actually sufficient for the framework—the ObjectMaterializer’s only requirement on the constructors for the objects it creates is that there be a constructor which takes no parameters.[i]
So the only change required to simplify the custom construction logic story was to modify EdmGen’s class generation system to no longer output any constructors for entity classes. Now if you want to add construction logic, you need only implement a constructor in the partial class of your entity object class just like you would for any class. The only requirement for the constructors is that if you implement a constructor which takes parameters you must be sure to also implement one which takes no parameters (because the CLR will not supply a default constructor if you supply any constructors and the ObjectMaterializer requires a constructor with no parameters).
So in the next CTP (after beta 1), the Entity Framework no longer defines the method DoFinalConstruction or requires any of the mechanisms described in the previous article. Good bye DoFinalConstuction() and good riddance.
[i] Note: We are evaluating a further change to make the ObjectMaterializer even more flexible so that it could construct object instances using factory methods and not even require a parameterless constructor, but we have not yet committed to that change, and it certainly won’t be in the next CTP.
Hey folks, It has been longer in arriving than I would have liked, but the June CTP of the Entity Framework
There was an interesting discussion on the LINQ Project General forum today (scroll down toward the end
Entity Framework FAQ Version 0.1 – first draft Contents 1. Introduction . 3 1.1. Why use EDM? How does
Version 0.1 – first draft, November 8, 2007 Contents 1. Introduction 1.1. About this FAQ… 1.2. Where
The Entity Framework enables developers to reason about and write queries in terms of the EDM model rather than the logical schema of tables, joins, foreign keys, and so on. Many enterprise systems have multiple applications/databases with varying degrees
Part of the Entity Framework FAQ . 2. Architecture and Patterns 2.1. Does Entity Framework have support