6. Designer Options

In the last chapter you had a quick peek at adding a code generation item to an Entity Framework model in order to control, well, the code it generates. In this chapter we’ll look at this process in more detail. As you’ll see, Entity Framework provides templates for three common code strategies: entity objects (which you get by default, but using the template provides more control), the DbContext objects that we examined in the last chapter, and self-tracking entities, which are useful in n-tier applications (we’ll use them in the final project in Chapter 10).

These templates are provided by the Entity Framework team. (If you search the template gallery, you’ll find others that are provided by the team or by members of the development community.) They’re actually examples of T4 templates. T4 stands for TEXT TEMPLATE TRANSFORMATION TOOLKIT (but everybody just calls them “T4 templates”). T4 gives you complete control over what code the designer produces from the model, and we’ll take a look at how that works at the end of the chapter. But before we get to that tricky total control stuff, we’ll start the chapter by exploring the 2nd of the Entity Framework workflows: Model-First. Instead of starting with a database and using the wizard to create a model, we’ll start with the model and get a wizard to create (and re-create) the database for us.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset