MSDN Magazine - February 2008 - (Page 31) Designing an Entity Data Model JOHN PAPA T he Entity Framework is an exciting new technology being developed for ADO.NET. It allows developers to view data using a logical model instead of a physical model, offering more flexibility. I gave a detailed overview of the Entity Framework (which is due in the first half of 2008) in the July 2007 installment of Data Points. If you’re not yet familiar with the Entity Framework, you can read my overview at msdn.microsoft.com/ Studio® 2008 and the corresponding Entity Framework Beta 3 (these require separate installations). The database I am using is the revised Northwind database that comes with the samples for Beta 3. Before I dive into how to create and manage an entity model, let me first explain what the EDM is and how it interacts with the msdnmag/issues/07/07/DataPoints. other elements of the Entity Framework. The At the heart of the Entity Framework is Entity Framework consists of many pieces, the Entity Data Model (EDM). The EDM including the EDM specification and assodefines the entity types, relationships and ciated mappings, APIs that interact with the containers that developers interact with via EDM, and tools that help define and manage code. The Entity Framework maps these elthe entity model and mappings. Once you’ve ements onto the storage schema exposed by designed an entity model, you can write code a relational database. The EDM is exposed against it using the different APIs, such as the to the Entity Framework through XML that EntityClient provider, or Object Services (indefines the conceptual application model. cluding LINQ to Entities). The conceptual model may be defined sepaThe EntityClient data provider has a simiFigure 1 Entity Framework Overview rately, or together with XML that defines the lar model to traditional ADO.NET objects, as actual storage schema along with XML that defines the mapping it uses EntityConnection and EntityCommand objects to return a between the two. While it is possible (and sometimes necessary) DbDataReader. The commands for the EntityClient provider are to manually edit the XML, it is much easier to create and modify written using Entity SQL, which is similar to T-SQL, but, instead an entity model and mapping using the new visual Entity Data of operating on database objects, it operates on the entities defined Model designer tool. in the entity model and on the objects materialized through Object In this month’s column, I will discuss how you can design an entity model using the new visual EDM designer tool and how you can modify the underlying XML that defines both the model and the mapping. I’ll start by describing all of the pieces that interact within the Entity Framework (including LINQ) and will then discuss where the EDM fits. Furthermore, I will demonstrate how to create an entity model and associated mappings using the visual designer tool. Finally, I will introduce you to several windows that can help you modify and explore the model and mappings. Throughout the column, I will explain the roles of the different components of the EDM, such as the EntityType and Association. The examples in this column demonstrate how to create basic entities. Note that all the examples in this column use Visual This column is based on a prerelease version of Visual Studio 2008 and the ADO.NET Entity Framework. All information herein is subject to change. Understanding the EDM Figure 2 Entity Framework Connects an App to its Database february2008 31 http://msdn.microsoft.com/msdnmag/issues/07/07/DataPoints http://msdn.microsoft.com/msdnmag/issues/07/07/DataPoints
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.