Compartir a través de


Entity Framework and Other Platforms

Most applications make extensive use of relational databases. Developers need a data model that connects application code to storage structures.

The Entity Data Model (EDM) supports application scenarios across various storage models and maps to both the CLR and to database management systems such as SQL Server. Mapping to the CLR is required for programmability, and mapping to relational databases is required for persistence. With the introduction of the EDM, ADO.NET provides a comprehensive platform for mapping programmable types to storage.

There are at least four existing platforms that are candidates for a new data model:

  • SQL Server

  • Common language runtime (CLR)

  • Unified modeling language (UML)

  • XML schema definition (XSD) language

None of the existing platforms fill all the requirements of data applications.

  • SQL Server does not provide easy integration with programming languages. Its text-based queries are often cumbersome in code. Database tables model relationships using foreign keys. SQL cannot model strict containment.

  • The CLR does not have the constraints needed to model relationships.

  • UML is too abstract. It does not implement data types or persistence.

  • The XSD specification is too different from programming-language classes and database schemas to provide a neutral format for mapping to both the CLR and to relational database models.

EDM Mapping to CLR and Database Management Systems

The EDM maps to both the CLR and relational databases. The CLR enables developers to use data in familiar coding formats. Data types in code map to relational databases, the proven standard for data persistence.

To implement mapping among schemas, programming languages, and database tables, the EDM uses a store-independent view mechanism that takes advantage of the engineering of relational database management systems. Conventional applications already use database views for data display and updates, but constructing views often requires complex SQL syntax involving table joins and projections. The EDM mapping between schemas and storage connects objects in code with the database through a ADO.NET data provider.

The EDM data services are not dependent on any particular storage schema. Applications that require multiple data sources can maintain individual mappings for each data source.

Development Platform

The EDM supports application design in each phase of implementation. The EDM supports many useful existing constructs, and its design uses concepts drawn from well-defined data modeling systems such as the relational database model, the entity-relationship model, and the common language runtime (CLR).

The EDM models complex application features and declaratively captures semantic relationships between programmable objects and database storage.

The EDM encompasses the features of the relational database model and extends it by adding strong-typing, entity-level identities, references, and relationships.

Because the EDM specification is extensive, you can use a subset of the EDM specification. For example, an application or framework can use entities, associations, and references, and not use inheritance.

The EDM is extensible according to two principles:

  • New types and extensions to existing types can be defined by using inheritance. Applications can define relationships among types and across schema boundaries.

  • Extensions to existing data built on the EDM do not affect features that do not use the extensions.

Inter-application and inter-framework sharing can be achieved by defining application data models in terms of the EDM. The namespace defined for one application can be used from another application built according to the EDM.

The query model is designed to be closed under relational algebra. This means that applying relational operators on EDM concepts returns results that are also in the EDM.

Integrating the EDM with the CLR captures versatile data semantics. The EDM type system maps declarations in programming languages to data in the underlying storage structures.

The entities of the EDM are logically independent of the persistence implementation used. The data model does not dictate any specific mapping or implementation and entities can be mapped to a variety of physical data sources. The EDM is not intended to subsume or replace the SQL Server data definition language (DDL).

Design Stages

The design and implementation of a data model using the EDM specification requires three preliminary phases of development. In order, here is what occurs in each phase of the process.

  • Entities and relationships in the domain of the application are specified in an XML file.

  • Metadata describing the structures of the database that will store data for the application is specified in a second XML file.

  • The entities and relationships in the first schema are mapped to corresponding database structures in the metadata file.

The first schema represents a conceptual phase of development in which entities and relationships are defined by using an XML syntax called conceptual schema definition language (CSDL). Files of this kind have the extension .csdl. For more on CSDL syntax, see Schemas (EDM).

The storage metadata schema uses store schema definition language (SSDL).

Mapping conceptual schemas to storage metadata uses a third XML syntax called mapping specification language (MSL). For information about mapping entities and relationships and the types of EDM schemas, see Schemas and Mapping Specification (Entity Framework).

The CSDL schema is used to generate the programmable object model used by application code. Languages that support the common language runtime (CLR) can use the object model created by the build process. For examples of application code, see Sample Applications (Entity Framework).

See Also

Concepts

Implementing Entities (EDM)
Implementing Associations (EDM)

Other Resources

EDM Specifications
Sample Applications (Entity Framework)