Chapter 5. Domain model mapping

 

This chapter covers

  • Introducing the Entity Data Model
  • Creating Entity Framework domain model classes
  • Describing classes
  • Describing database
  • Mapping classes to database

So far, you’ve learned how to create an application from scratch, defining a model, mapping it to the database, and performing queries on it. We also looked at creating and mapping classes using the Visual Studio designer, which hides a lot of complexity, making your life easier. But a strong knowledge of the Entity Data Model and the code in the model classes is fundamental to mastering Entity Framework. In this chapter, we’ll dig deep into both subjects so that you’ll be able to completely understand this aspect of Entity Framework. This chapter covers the mapping of tables or views to entities. Other features, like stored procedures and function mappings, will be discussed in later chapters.

We’ll first look at the Entity Data Model, its concepts, and Microsoft’s vision about its future. After that, we’ll discuss how to create entities and map them. You’ll learn how to write an entity from scratch and create the three mapping files that allow you to map it to the database. You’ll see how Entity Framework 4.0 supports POCO (plain old CLR objects) entities and how this positively affects classes.

5.1. The Entity Data Model

5.2. Creating consumable entities

5.3. Defining relationships in the model

5.4. Mapping inheritance

5.5. Extending the EDM with custom annotations

5.6. Summary