Modeling and Mapping with Entity Framework Designer

[This page is specific to the latest version of the Entity Framework. The latest version is available as the 'Entity Framework' NuGet package. For more information, see Entity Framework Releases and Versioning.]

The Entity Framework supports various ways to map conceptual models to relational data. The topics in this section describe common mapping and modeling tasks and scenarios supported by the Entity Designer.

Mapping scenario Description

Simple mapping

In this mapping scenario, each entity in the conceptual model is mapped to a single table in the storage model. This is the default mapping generated by Entity Data Model tools. For more information, see the Quickstart (Entity Framework).

Entity splitting

In this mapping scenario, properties from a single entity in the conceptual model are mapped to columns in two or more underlying tables. In this scenario, the tables must share a common primary key.

Horizontal partitioning in the conceptual model

In this mapping scenario, multiple entity types in the conceptual model that have the same properties are mapped to a single table. A condition clause is used to specify which data in the table belongs to which entity type. This mapping is similar to table-per-hierarchy inheritance mapping.

Table-per-hierarchy inheritance

In this mapping scenario, all types in an inheritance hierarchy are mapped to a single table. A condition clause is used to define the entity types.

Table-per-type inheritance

In this mapping scenario, all types are all mapped to individual tables. Properties that belong solely to a base type or derived type are stored in a table that maps to that type.

Table-per-concrete-type inheritance

In this mapping scenario, non-abstract types are each mapped to an individual table. Each of these tables must have columns that map to all of the properties of the derived type, including the properties inherited from the base type.

Multiple entity sets per type

In this mapping scenario, a single entity type is expressed in two or more separate entity sets in the conceptual model. Each entity set is mapped to a separate table in the storage model.

Complex types

A complex type is a non-scalar property of an entity type that does not have a key property. A complex type can contain other nested complex types. Complex types are mapped to tables in the storage model. For more information, see How to: Create and Modify Complex Types.

Function import mapping

In this scenario, a stored procedure in the storage model is mapped to a FunctionImport element in the conceptual model. This function is executed to return entity data using the mapped stored procedure. For more information, see How to: Import a Stored Procedure.

Modification function mapping

In this scenario, stored procedures are defined in the storage model that insert, update, and delete data. These functions are defined for an entity type to provide the update functionality for a specific entity type.

Defining query mapping

In this scenario, a query is defined in the storage model that represents a table in the data source. The query is expressed in the native query language of the data source, such as Transact-SQL when mapping to a SQL Server database. This DefiningQuery element is mapped to an entity type in the conceptual model. The query is defined in the store-specific query language. For more information, see How to: Add a Defining Query. When you use a defining query, updates cannot be persisted to the data source using the standard update process. Updates can be made by defining modification function mappings.

Query view mapping.

In this scenario, a read-only mapping is defined between entity types in the conceptual model and relational tables in the storage model. This mapping is defined based on an Entity SQL query against the storage model that returns entities in the conceptual model. For more information, see QueryView Element. When you use a query view, updates cannot be persisted to the data source using the standard update process. Updates can be made by defining modification function mappings.

AssociationSet mapping

Associations define relationships between entities. In a simple mapping with a one-to-one or one-to-many association, associations that define relationships in the conceptual model are mapped to associations in the storage model. The following more advanced association set mappings are also supported:

  • Many-to-many associations. Both ends of the association are mapped to a link table in the storage model.

  • Self association. This supports an association between two entities of the same type, such as an Employee with an association to another Employee.

See Also

Concepts

Querying Data
Working with Objects (Entity Framework)

Other Resources

Entity Framework Resources

Build Date:

2013-06-19