Databases Reference
In-Depth Information
NOTE
Complete discussion of text template is outside the scope of this topic. You can find
detailed information on this topic at http://www.olegsych.com/2007/12/text-template-
transformation-toolkit.
You can modify TT files using any text editor, such as the one that comes with Visual
Studio. To accomplish the immediate goal of changing the base class of the generated
NorthwindEntities , search for the word ObjectContext in the template and replace it
with UnleashedObjectContext , as shown in Figure 8.3. When you save the TT file, the
Northwind.cs under it is automatically regenerated and the NorthwindEntities class will
inherit from the new base class.
FIGURE 8.3
Changing context base class in the text template.
NOTE
Visual Studio does not offer color syntax highlighting and IntelliSense for TT files.
You can download one of several third-par ty add-ons that provide these capabilities.
Figure 8.3 shows the Devart T4 Editor available for download at http://www.devart.com/
t4-editor.
Customizing Text Template to Generate Static Constructors
The Entity Framework text template in the sample solution has been further customized
to automatically generate static constructors for every entity type as discussed in the
Registering Metadata Provider with TypeDescriptor section. The following code is now a part
of the generated classes and does not need to be hand-coded:
Search WWH ::




Custom Search