.edmx File Overview
An .edmx file is an XML file that defines an Entity Data Model (EDM), describes the target database schema, and defines the mapping between the EDM and the database. An .edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically. The recommended practice for creating an .edmx file is to use the Entity Data Model Wizard. For more information, see How to: Create a New Entity Data Model.
Changes are made to an .edmx file when you use the Entity Designer to modify your model and when you use the Update Model Wizard to update your model based on changes to the underlying database. For more information, see Update Model Wizard. There are also some scenarios in which you might have to edit an .edmx file manually. For more information, see Editing an .edmx File Manually.
The contents of an .edmx file define the properties of a conceptual model. The MetadataArtifactProcessing and ValidateOnBuild properties are described later in this topic. The following topics provide more information about conceptual model properties:
How to: Edit Conceptual Model Properties: Provides information about viewing and editing conceptual model properties in the Entity Designer.
Namespace Attribute (CSDL): Provides information about the Namespace property of the conceptual model.
Name Attribute (EntityContainer CSDL): Provides information about the EntityContainerName property of the conceptual model.
Note
The conceptual model properties are not the same as the properties of the .edmx file itself. For more information, see .edmx File Properties.
By default, an .edmx file opens with the Entity Designer. However, you can open an .edmx file with the XML Editor by following these steps:
Make sure your project is open in Visual Studio.
Right-click the .edmx file in Solution Explorer and select Open With...
Select XML Editor and click OK.
.edmx File Contents
The following is a high-level breakdown of the contents of an .edmx file. For more details, see Schemas and Mapping Specification and the .edmx schema (Microsoft.Data.Entity.Design.Edmx.xsd) in your Visual Studio XML directory.
Runtime Content (edmx:Runtime): This section contains information that is used to generate model and mapping files for Entity Framework applications. For more information, see the Build Action property in .edmx File Properties.
Note
An .edmx file is automatically added to an application that references an ADO.NET Data Services service. In this case, the .edmx file contains an edmx:DataServices node, not an edmx:Runtime node. For more information, see ADO.NET Data Services Framework.
Storage Model Content (edmx:StorageModels): This section describes the target database schema and is written in store schema definition language (SSDL). For more information, see Storage Metadata Schema (SSDL) and EntityContainer Element (SSDL).
Conceptual Model Content (edmx:ConceptualModels): This section defines the entity types, complex types, associations, entity containers, entity sets, and association sets in the application domain. This section is written in conceptual storage definition language (CSDL). For more information, see Conceptual Schema (CSDL) and EntityContainer Element (CSDL).
Mapping Content (edmx:Mappings): This section describes the mapping between the conceptual model and the target database, and is written in mapping specification language (MSL). For more information, see Mapping Specification (MSL).
Designer Content (edmx:Designer): This section contains information that is used by the Entity Designer to render a conceptual model graphically and to define some conceptual model and design-time properties.
Note
An .edmx file is automatically added to an application that references an ADO.NET Data Services service. In this case, the .edmx file does not contain an edmx:Designer node and is not viewable with the Entity Designer. For more information, see ADO.NET Data Services Framework.
Connection Content (edmx:Connection): This section describes conceptual model properties that affect the connection string. Currently, the only property you can set in this section is the MetadataArtifactProcessing property. For more information, see Connection Strings (Entity Framework).
Options Content (edmx:Options): This section describes optional conceptual model properties. Currently, only the ValidateOnBuild property is set here.
Diagrams (edmx:Diagrams): This section contains information that is used by the Entity Designer to render a graphical display of the conceptual model.
In This Section
- .edmx File Properties
Describes the properties of an .edmx file.
- Generated Code Overview (Entity Data Model Tools)
Provides an overview of code that is generated from an .edmx file.
- Editing an .edmx File Manually
Provides information about editing an .edmx file for specific modeling and mapping scenarios.
See Also
Other Resources
EDM Specifications
Schemas and Mapping Specification (Entity Framework)