tailieunhanh - CHAPTER 1 ■ INTRODUCING THE ADO.NET 4.0 ENTITY FRAMEWORK The first version of the Entity

CHAPTER 1 ■ INTRODUCING THE ENTITY FRAMEWORK The first version of the Entity Framework gave the Entity Name and the Entity Set Name the same name. There was no attempt to singularize or pluralize names when generating a model from a database. The problem is that this caused some confusion when referencing the database table or EntityType in code. For example, if your database has a table called Employees, then you will also get an EntityType called Employees as well. This causes confusion about whether you are referencing the table or the EntityType, such as in the code fragment. | CHAPTER 1 INTRODUCING THE ENTITY FRAMEWORK The first version of the Entity Framework gave the Entity Name and the Entity Set Name the same name. There was no attempt to singularize or pluralize names when generating a model from a database. The problem is that this caused some confusion when referencing the database table or EntityType in code. For example if your database has a table called Employees then you will also get an EntityType called Employees as well. This causes confusion about whether you are referencing the table or the EntityType such as in the code fragment below. Customers customer new Customers Luckily this issue has been addressed. The model wizards both the Entity Data Model and Update Model Wizards now provide the option of using singular or plural forms of names for entities entity sets and navigation properties. The goal of this change was to make the application code much easier to read and avoid a lot of the confusion between object names. More on the EDM is discussed in Chapter 2. Complex Types A big addition to this version of the Entity Framework is the support for complex types. Complex types are like entities in that they consist of a scalar property or one or more complex type properties. Thus complex types are non-scalar properties of entity types that enable scalar properties to be organized within entities. Complex types are discussed in detail in Chapter 3. Customized Object-Layer Code Generation Object-layer code is generated by default by the EDM using the Entity Model Code Generator tool. This version of the Entity Framework allows developers to add text templates to a project that replaces the default tool to generate the object-layer code. By using custom text templates the EDM will generate the object context and entity classes. The Entity Framework makes it very easy to add custom templates via the EDM. Complex Types are discussed in detail in Chapter 3. Model Browser Improvements Several improvements have been

TỪ KHÓA LIÊN QUAN