Chapter 13. Customizing code and the designer

 

This chapter covers

  • Understanding the Visual Studio T4 mechanism
  • Customizing code generation
  • Customizing database DDL generation
  • Customizing the designer

You know that by default the Visual Studio designer generates Entity Framework 1.0–style classes. You also know that these classes are generated through a template. What’s great is that you can modify this template, or create new templates, to generate classes to fit your needs. You’ve already seen an example in chapter 2, when we introduced the POCO template provided by Microsoft. Another point where templates help in generating code is during database DDL generation from the storage model (when you use the model-first approach). You’ll learn about that later in this chapter.

When you modify templates to change the way CLR code or database DDL is generated, you have to deal with different Entity Framework features and other products in the .NET framework.

Metadata is an important feature that you must use to be able to modify templates. When you create or modify classes in the designer, only the EDMX file is modified; the template generates the code on demand. It reads the conceptual schema metadata and generates the code based on that data. The same way, when the database DDL is generated, the storage and mapping schema are generated. After that, the storage schema data is used to create the DDL. Everything is metadata-driven.

13.1. How Visual Studio generates classes

 
 

13.2. Customizing class generation

 
 
 

13.3. How Visual Studio generates database DDL

 
 
 

13.4. Customizing DDL generation

 

13.5. Creating designer extensions

 
 

13.6. Summary

 
 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest