Поделиться через


Data Modeling in the Entity Framework

The Entity Data Model (EDM) is an entity relationship model. The EDM defines data in a neutral format not constrained by the structure of programming languages or relational databases. EDM schemas are used to specify the details of entities and relationships and to implement them as data structures.

An entity is something in the application domain that must be represented by data. Examples of entities and relationships can be found in a typical line of business (LOB) application. Entities in the domain of an LOB application might include customers, orders, order-lines, suppliers, products, salespeople, shippers, invoices, and so on. An EDM EntityType is the specification for a data type that represents the entity in the application domain.

A relationship is the logical connection between entities: for example, the logical connection between a merchandise order and the customer who makes the order. Because a customer can have many associated orders, the relationship between a customer and that customer's orders is a one-to-many relationship. Products and suppliers might have a many-to-many relationship.

Defining entities and relationships can be a very complex process. Something as basic as a merchandise order in an LOB application requires a surprising amount of detail. For example, a merchandise order can take several forms. There might be a store order, a telephone order, an Internet order, and a catalogue order. In the EDM, the details of each type of order are specified conceptually in XML syntax. The properties of each type of order and any necessary constraints propagate to applications that use data built on the conceptual schema.

The EDM models entities and their relationships by using two basic types.

  • EntityType: The abstract specification for the details of a data structure in the application domain.

  • AssociationType: The logical connection between types.

An EDM design schema defines the structure, semantics, constraints, and relationships of entities in the domain of an application. In the EDM implementation of object services, the conceptual schema is mapped to another schema that contains metadata describing the storage model, usually tables in a database. The conceptual schema is used to generate the classes of a programmable object model that will be used in application code. The conceptual schema and storage schema are also used by the Entity Framework to validate, query, and update application data at runtime.

In This Section

See Also

Concepts

Implementing Entities (EDM)
Implementing Associations (EDM)
Entity SQL Language

Other Resources

EDM Specifications
Sample Applications (Entity Framework)