Entity Data Model (EDM)
A foundational concept in Entity Framework
Introduction to the Entity Data Model
The Entity Data Model (EDM) is a conceptual model that represents the structure of data within an application. It is independent of the underlying storage model (like a relational database schema) and focuses on the business entities and their relationships. Entity Framework uses the EDM to abstract data access, allowing developers to work with objects that directly map to their business domain, rather than raw database tables and columns.
Key Components of an EDM
1. Entity Types
An entity type represents a specific type of object in your domain, such as a Customer
, Product
, or Order
. Each entity type has a set of properties that define its data.
- Properties: Attributes of an entity, like
FirstName
,LastName
,Price
. - Key Properties: One or more properties that uniquely identify an instance of an entity type.
2. Entity Sets
An entity set is a collection of instances of a particular entity type. Think of it as a table in a database, but at the conceptual level. For example, a Customers
entity set would contain all instances of the Customer
entity type.
3. Associations
Associations represent the relationships between entity types. These relationships are directional and define how entities can navigate to related entities. An association consists of one or more Association Ends, each pointing to an entity set and defining the Multiplicity (one-to-one, one-to-many, or many-to-many).
- Multiplicity: Specifies the number of instances of one entity type that can be associated with instances of another entity type (e.g.,
1
for one,*
for many).
4. Complex Types
Complex types are non-entity types that are composed of other properties (which can be simple or other complex types). They are used to group related properties but do not have their own key. For example, an Address
could be a complex type with properties like Street
, City
, and ZipCode
.
Visualizing the EDM: The Entity Data Model Designer
Entity Framework provides a visual designer within Visual Studio that allows you to create and manage your EDM. You can drag and drop entities, define their properties, establish relationships, and generate the underlying database schema or import an existing one.

Figure 1: An example of the Entity Data Model Designer in Visual Studio.
Benefits of Using an EDM
- Abstraction: Hides the complexities of the underlying data store.
- Productivity: Enables developers to work with familiar object-oriented concepts.
- Maintainability: Centralizes data access logic, making it easier to manage and update.
- Decoupling: Separates the data access layer from the business logic.
How the EDM is Represented
When you work with Entity Framework, the EDM is typically represented by one of the following:
- Model-First: You design your EDM visually in the designer first, and then Entity Framework generates the database schema.
- Database-First: You have an existing database, and Entity Framework generates the EDM based on its schema.
- Code-First: You define your entity classes in code, and Entity Framework infers the EDM and database schema from your classes.
Example: Customer and Order Entities
Consider a simple scenario with Customer
and Order
entities.
Customer Entity Type
- Properties:
CustomerId
(Key),FirstName
,LastName
,Email
Order Entity Type
- Properties:
OrderId
(Key),OrderDate
,TotalAmount
An Association could link Customer
to Order
with a one-to-many multiplicity (one customer can have many orders).
// Conceptual representation (not actual C# code)
entity Customer {
int CustomerId // Key
string FirstName
string LastName
string Email
ICollection Orders // Navigation property
}
entity Order {
int OrderId // Key
DateTime OrderDate
decimal TotalAmount
Customer Customer // Navigation property
}
Next Steps
Understanding the Entity Data Model is crucial for effectively using Entity Framework. Explore the different approaches to defining your EDM (Model-First, Database-First, Code-First) and learn how to map your conceptual model to your data store.