Danh mục

Pro Entity Framework 4 0 Depositfiles_1

Số trang: 26      Loại file: pdf      Dung lượng: 1.19 MB      Lượt xem: 9      Lượt tải: 0    
tailieu_vip

Phí tải xuống: 1,000 VND Tải xuống file đầy đủ (26 trang) 0
Xem trước 3 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Việc giới thiệu SQL Server 2005 đã bắt đầu quá trình đó đã nhìn thấy. NET trở thành một phần không tách rời của công nghệ cơ sở dữ liệu SQL Server. SQL Server 2008 là bước tiến hóa tiếp theo trong câu chuyện đó. Cùng với những cải tiến cơ sở dữ liệu truyền thống trong bản phát hành mới, tập trung ngày càng tăng khi hội nhập lớn hơn và nhiều thử thách hơn với. NET 3.5. Cuốn sách này cho thấy làm thế nào để tận dụng lợi thế này tích hợp chặt chẽ và làm thế...
Nội dung trích xuất từ tài liệu:
Pro Entity Framework 4 0 Depositfiles_1 CHAPTER 3 ■ THE ENTITY DATA MODEL INSIDE AND OUT The Designer is the tool that allows you to work with the EDM and provides the functionality developers need to create, modify, and update the EDM. The Designer consists of several components to assist you in designing and editing your conceptual model. Figure 3-2 shows the different components, including the following: Designer surface: A visual surface for creating and modifying the conceptual • model. Mapping Details window: The location where mappings are created or modified. • The window is discussed later in the chapter. Toolbox: Contains controls that can be used to create entities, associations, and • inheritance relationships. Model Browser window: Provides a view of the conceptual model and the • associated storage model. Model Browser Window The Model Browser window provides a tree view of the conceptual and storage models that are defined in the EDM (specifically, the .edmx). The information in this window is organized by the type of information contained within the window, as shown in Figure 3-2. The first node displays the information found in the conceptual model, such as entities and associations. The second node displays the storage model components, i.e., those components of the database that have been imported into the model, such as tables, views, and stored procedures. Within the Model Browser window you can Locate an entity on the Designer surface by right-clicking the entity and selecting • Show in Designer from the context menu Delete objects from the storage model, including stored procedures, tables, and • views Create function imports from stored procedures by right-clicking on a stored • procedure and selecting Add Function Import from the context menu Update the model from the database • As you select items in the Model Browser window, these items become the active object in the Properties and Mapping windows, making it easy to modify and work with EDM objects. 37 CHAPTER 3 ■ THE ENTITY DATA MODEL INSIDE AND OUT Figure 3-2. Designer surface and windows Mapping Details Window The Mapping Details window provides an interface enabling you to view and edit the physical mappings between the storage and conceptual models. Through this window you can view and modify the mappings for the tables and views as well as map entities to functions (stored procedures). When an entity is selected in the Designer, the Mapping Details window shows the mapping between the entity properties and the table column in the storage model. For example, in Figure 3-2 you can see the Person entity is selected in the Designer as well as the Mapping Details window showing the mapping between the table columns and the properties of the Person entity. Within this window you can change the individual property mappings or assign imported stored procedures as functions to perform Insert, Update, and Delete operations. With an understanding of the different windows in the Designer, let’s move on and discuss the different components in the EDM Designer itself. Entities To understand the Entity Framework and how entities work, there are a few concepts that you should know: Entity type: This represents a particular type of data, such as Employee, Order, or • Product. Entity types are highly structured records with a key. Entity set: This is a logical container for entities of a single type. • 38 CHAPTER 3 ■ THE ENTITY DATA MODEL INSIDE AND OUT Entities, therefore, are instances of entity types, and entities can be grouped into entity sets. The model in Figure 3-3 illustrates this concept, which includes three entity types (SalesPerson, SalesOrderHeader, and SalesOrderDetail), two entity sets (SalesPerson and SalesOrder), and relationships between the three entity types. Figure 3-3. Entity and EntitySets With the explicit concept of entities and relationships, developers can now describe schemas more precisely by using entities to provide the formal design for the details of a data structure. In other words, the formal design should specify how an application will encapsulate the different types and kinds of data in a logical structure. The EDM model we created earlier came from the AdventureWorks database, which contains Employees, Products, Sales, and more. Each of these represents a data structure and entities are the formal specifications of the details of those structures. An Order type, for example, contains details such as salesperson, order date, and quantity. A SalesPerson type could contain name, address, and other pertinent information. The EDM represents a logical connection between the SalesPerson and the Order as a relationship, or association. You’ll also notice that the entity set is defined in the properties of the entity itself. For example, Figure 3-4 shows the Employee entity selected with the Properties page opened showing the properties for that entity. One of the properties of the entity is the Entity Set Name. In this example the property takes on the plural version of the entity name, in this case, Employees. This property is editable, and as such allows you to change the entity set name and add multiple entities to the same entity set. Figure 3- ...

Tài liệu được xem nhiều: