Entity Data Model

The Entity Data Model (EDM) is a conceptual model that describes the data and its structure in an abstract way, independent of the underlying storage. It provides a unified view of data from potentially disparate data sources.

Core Concepts of the EDM

Benefits of Using the EDM

EDM Tools and Components

The Entity Framework provides tools for defining and working with the EDM:

Key Takeaway:

The Entity Data Model acts as an abstraction layer, enabling developers to interact with data using a domain-driven approach without direct exposure to the underlying database structure.

Example Structure (Conceptual)

Consider a simple e-commerce scenario:

Entities:

Relationships:


<!-- Conceptual Schema Definition (CSDL) Snippet -->
<Schema Namespace="MyCompany.eCommerce" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
  <EntityType Name="Customer">
    <Key>
      <PropertyRef Name="CustomerId" />
    </Key>
    <Property Name="CustomerId" Type="Edm.Int32" />
    <Property Name="FirstName" Type="Edm.String" />
    <Property Name="LastName" Type="Edm.String" />
    <Property Name="Email" Type="Edm.String" />
    <NavigationProperty Name="Orders" Relationship="MyCompany.eCommerce.CustomerOrders"
                      FromRole="Customer" ToRole="Order" />
  </EntityType>

  <EntityType Name="Order">
    <Key>
      <PropertyRef Name="OrderId" />
    </Key>
    <Property Name="OrderId" Type="Edm.Int32" />
    <Property Name="OrderDate" Type="Edm.DateTime" />
    <Property Name="TotalAmount" Type="Edm.Decimal" />
    <NavigationProperty Name="Customer" Relationship="MyCompany.eCommerce.CustomerOrders"
                        FromRole="Order" ToRole="Customer" />
    <NavigationProperty Name="Products" Relationship="MyCompany.eCommerce.OrderProducts"
                        FromRole="Order" ToRole="Product" />
  </EntityType>

  <EntityType Name="Product">
    <Key>
      <PropertyRef Name="ProductId" />
    </Key>
    <Property Name="ProductId" Type="Edm.Int32" />
    <Property Name="ProductName" Type="Edm.String" />
    <Property Name="Price" Type="Edm.Decimal" />
    <NavigationProperty Name="Orders" Relationship="MyCompany.eCommerce.OrderProducts"
                        FromRole="Product" ToRole="Order" />
  </EntityType>

  <Association Name="CustomerOrders">
    <End Type="MyCompany.eCommerce.Customer" Role="Customer" />
    <End Type="MyCompany.eCommerce.Order" Role="Order" />
  </Association>

  <Association Name="OrderProducts">
    <End Type="MyCompany.eCommerce.Order" Role="Order" />
    <End Type="MyCompany.eCommerce.Product" Role="Product" />
  </Association>
</Schema>