The Entity Data Model is an Entity-Relationship data model. The central concepts in the EDM are entities and relationships. It is the layer between the Entity Framework and the database.
EDM provides the conceptual schema(CSDL), a representation of the database(SSDL), a mapping file(MSL), and access to an Entity Framework-aware ADO.NET provider for the target database. Due to EDM the Entity Framework doesn't care what database is being targeted. It provides a common means of interacting with the database, common query syntax, and a common method for sending changes back to the database. EDM uses EDMX file to manage conceptual schema, storage schema and their mappings. Check the screenshot displayed below for more details. I will provide more details on EDMX file in my next post.
We are not going to go more deep inside EDM, I am just going to provide an overview of some of the basic concepts of EDM e.g Types, Instances and Relationships
Types
- EntityType: An EntityType defines the data objects which contains the information needed for the application perspective such as Employee, Account, things or activities relevant to the application. An Entity is an instance of an EntityType. It has a unique identity, independent existence, and forms the operational unit of consistency.
1: <EntityType Name="Employee" Key="EmployeeId">
2: <Property Name="FirstName" Type="String" Nullable="false"/>
3: <Property Name="LastName" Type="String" Nullable="false"/>
4: <Property Name="EmailID" Type="String" Nullable="true"/>
5: </EntityType>
- Property: An EntityType can have one or more properties of the specified SimpleType, ComplexType, or RowType. Properties can be either single-valued or multi-valued. For example can be of type built in or can have type which returns array of values.
- EntityKey: All instances of an EntityType are uniquely identified by the an EntityKey. It also helps to update entity instances and to allow entity instances to participate in relationships.
- ComplexType: It represents a set of related information. Like EntityType, it consists of one or more properties of SimpleType, ComplexType, or RowType. However unlike EntityType, ComplexType is not associated with an EntityKey.For example Customer is one an EntityType, and Customer have address. So we can use it as a Complex property inside Customer Entity.
1: <ComplexType Name="Address">
2: <Property Name="AddressLine1" Type="string"/>
3: <Property Name="AddressLine2" Type="string"/>
4: <Property Name="City" Type="string" fixedLength="30" />
5: <Property Name="State" Type="string"/>
6: <Property Name="Country" Type="int" nullable="false"/>
7: </ComplexType>
8: <EntityType Name="Customer" Key="CustomerId">
9: <Property Name="CustomerId" Type="String"/>
10: <Property Name="Name" Type="string" nullable="false"/>
11: <Property Name="Email" Type="string" nullable="true"/>
12: <Property Name="Address" type="Address"/>
13: </EntityType>
- RowType: It is an anonymous type that is structurally similar to ComplexType except that it cannot participate in type-inheritance. Two (anonymous) RowType instances are comparable if their corresponding RowTypes have the same number, sequence and type of properties.
- RelationshipType: While EntityTypes are like nouns of a data model, RelationshipTypes are the verbs that connect those nouns. A RelationshipType is described over two or more participating EntityTypes. The EDM supports two kinds of RelationshipTypes, Association and Containment. An Association is like a peer-to-peer relationship while Containment is a parent-child relationship with specific membership semantics
- Schema: All EDM types are contained within some namespace. The Schema concept defines a namespace that describes the scope of EDM types.
Below is a diagram of the EDM type hierarchy

Instances
- EntitySet: An EntitySet for an EntityType holds instances of its EntityType or any of its subtypes. Multiple EntitySets may be defined for a given EntityType.For example if in your database you have two tables Orders and OrdersBackup. Suppose Orders table is only for current year and OrdersBackup is updated at the end of the year to move all current year’s orders in to OrdersBackup table. Now suppose you do not want to have different entities in your application then you can combine Ordes and OrdersBackup table in to single entity in you application called “Orders”. In this way you do not need to specify another entity for OrdersBackup table.
- RelationshipSet: A RelationshipSet for a given relationship type may hold instances of that type. The relationship instance connects entity instances contained by the EntitySets participating in this RelationshipSet. A RelationshipSet description includes the RelationshipType and the corresponding EntitySets of the EntityTypes described in RelationshipType.
- EntityContainer: All EDM instance-based concepts like EntitySets and RelationshipSets are defined in the scope of an EntityContainer. Users can have one or more instances of EntityContainer. An EntityContainer can reference one or more Schemas.
Relationships in EDM
While entity types are the nouns of a data model, relationships are the verbs that connect those nouns. A relationship is a link between two or more Entities. For example a “Company have Designers, Designers builds websites, one or more websites belongs to a single Clients.”
In this sentence Company, Designers, WebSites and Clients are the Entities. The Company and Designers are linked via Have relationship, similarly Designers and Websites are linked via Build relationship. The relationship concept is taken from the Entity-Relation data model.
Characterization
Relationships are primarily characterized by its degree, multiplicity, direction and kind. This section describes these terms in more detail.
Degree
The degree of a relationship is the number of EntityTypes associated with it. The most common form of relationship is a binary relationship that relates two EntityTypes, ternary relates three EntityTypes and the most general form is the n-ary relationship that can relate n EntityTypes.
Multiplicity
The multiplicity of a relationship describes the cardinality or number of instances of an EntityType that can be associated with the instances of another EntityType. The basic types of multiplicity are:
zero or one ( "0..1" ), exactly one ( “1” ), zero or more ( "*" ), one or more ( "1..*" ), exactly n ( "n" )
and last is many-to-many ( "n..m" ) where n is less than or equal to m.
Direction
Relationship can be uni-direction or bi-directional. In Uni-directional the relation is just like a read-only relationship. Two-way relationship communicate in both ways i.e. applicatin and datasource both can interchange data via two way communication relationship. A bi-directional relationship instance can be seen as connecting entity-instances in both directions. The label or name given to a relationship-end is called Role. Role names are unique within a relationship.
Kind
The relationship kind determine the characteristics of the relationship i.e. Composition, Identifying, Association, Conditional Association, Relationship Properties and Containment (it is like a parent-child relationship and is described below)
- Conditional Association: The relationship is created based on the specified condition. The entity property is used to specify the conditional expression which determines whether the specific Entity is needed to be included in the RelationshipSet or not.
- Relationships with Properties: A relationship with properties is still a relationship and can be used in all places where a standard relationship could be used. Specifically it does not mean that relationship-with-properties can be an end of another relationship, an end of a relationship is always an entity. We use the Association relationship to further describe the concept of relationship with properties.For example the relationship between Project and Designers can have property like the number of Designers needed in the project. The Project and Designer are EntityType
1: <Association Name="ProjectsDesigners">
2: <End Type="Project" Multiplicity="1" role="Project" />
3: <End Type="Designer" Multiplicity="*" role="Designers" />
4: <Property Name="NrOfDesignersNeeded" Type="int" />
5: </Association>
- N-ary Relationships: A nary relationship can have more than two ends (or a degree greater than two). We use the Association relationship to further describe the concept of n-ary relationships. For example in below scenario Employee can perform tasks, tasks belongs to different Clients. So there is a n-ary relationship exists between EntityTypes Employee, Task and Client.
1: <Association Name="EmployeesTasksCustomers">
2: <End Type="Employees" Multiplicity="1" role="Employee" />
3: <End Type="Tasks" Multiplicity="*" role="PerformedTask" />
4: <End Type="Customers" Multiplicity="*" role="WorkedForClient" />
5: </Association>
- Parent-Child Relationship (Containment): This is a kind of relationship with the following characteristics:
- Direction: It is a bi-directional relationship with different semantics for each direction of the relationship.
- Multiplicity: This relationship is 1 to 0..N where the cardinality of one end is always 1. For convenience, we will refer to the 1-end as the parent, and the other end as the child.
- Exclusive membership constraint: A child EntityType may participate in multiple Containment relationships however a child entity-instance can be a member of exactly one Containment relationship-instance. In other words, a child entity-instance at all times is contained in exactly one parent entity-instance.
- Operational Behavior: A Containment child entity-instance always lives in the scope of its parent entity-instance. As a result the Action on OnDelete operation is restricted to be Cascade or Restrict with Cascade as the default.
The following example shows the definition of a Containment relationship:
1: <Containment Name="Parent_Child">
2: <End Type="Child" Multiplicity="*" role="Children" />
3: </Containment>
Inheritance in EDM
EDM also supports inheritance. Lets say we have Designer which is derived from Employee, then we can achieve this in the EDM like below
1: <EntityType Name="Employee" Key="EmployeeId">
2: <Property Name="FirstName" Type="String" Nullable="false"/>
3: <Property Name="LastName" Type="String" Nullable="false"/>
4: <Property Name="EmailID" Type="String" Nullable="true"/>
5: </EntityType>
6: <EntityType Name="Designer" baseType="Employee" >
7: <Property Name="IsFlashDesigner" Type="Boolean" Nullable="false" />
8: </EntityType>