Megosztás a következőn keresztül:


.edmx File Overview (Entity Framework)

An .edmx file is an XML file that defines a conceptual model, a storage model, and the mapping between these models. 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 .edmx File (Entity Data Model Tools).

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 (Entity Data Model Tools). 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 (Entity Framework).

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:

  1. Make sure your project is open in Visual Studio.

  2. Right-click the .edmx file in Solution Explorer and select Open With...

  3. 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 the .edmx schemas in your Visual Studio XML directory.

NoteNote

The schema for applications that target the .NET Framework version 4 is defined in the Microsoft.Data.Entity.Design.Edmx_2.xsd file. The schema for applications that target the .NET Framework version 3.5 SP1 is defined in the Microsoft.Data.Entity.Design.Edmx_1.xsd file.

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 the .edmx File Properties section below.

NoteNote

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 WCF Data Services.

  • Storage Model Content (edmx:StorageModels): This section describes the target database schema and is written in storage schema definition language (SSDL). For more information, see SSDL Specification 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 CSDL Specification 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 MSL Specification.

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.

NoteNote

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 WCF Data Services.

  • 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.

Conceptual Model Properties

The properties of a conceptual model are defined in an .edmx file. The following list describes conceptual model properties that are visible in the Visual Studio Properties window:

NoteNote

Conceptual model properties are not the same as the properties of the .edmx file itself. For more information, see the .edmx File Properties section below.

  • Connection String
    The entity client connection string. The connection string that is shown is taken from the project's App.config or Web.Config file and has the same name as the Entity Container name. For more information, see Connection Strings (Entity Framework).
  • Database Schema Name
    The schema name of the database that is generated when creating a database from a conceptual model.
  • Entity Container Access
    Controls whether the generated object context class is Public or Internal.
  • Metadata Artifact Processing
    Controls whether the model and mapping files (.csdl, .ssdl, and .msl files) are embedded in an output assembly or copied to the output directory.
  • Pluralize New Objects
    Controls whether new entity set names and navigation property names are pluralized.
  • Transform Related Text Templates On Save
    Text templates are related to an .edmx file by inserting the .edmx file name into the text template. For more information, see How to: Customize Object-Layer Code Generation (Entity Data Model Designer). When the Transform Related Text Templates On Save property is set to True, all text templates that are related to the .edmx file are processed when the .edmx file is saved. When the property is set to False, none of the related text templates are processed.
  • Validate On Build
    Controls whether the model is validated when the project is built.

.edmx File Properties

The Build Action, Custom Tool, and Custom Tool Namespace properties areproperties of an .edmx file. For more information about the Copy to Output Directory and File Name properties of an .edmx file, see File Properties in the Visual Studio documentation.

NoteNote

The Copy to Output Directory file property is not used to specify that model and mapping files should be copied to the output directory. Instead, use the Metadata Artifact Processing property of the conceptual model.

To view and edit .edmx file properties in Visual Studio, follow these steps:

  1. Open a project that contains an .edmx file in Visual Studio.

  2. Right-click the .edmx file in Solution Explorer and select Properties.

    The file properties are visible in the Properties window.

The following list describes the Build Action, Custom Tool, and Custom Tool Namespace properties of an .edmx file:

  • Build Action
    When this property is set to EntityDeploy (the default value), three files are created from the .edmx file when a build is executed: the conceptual model file (.csdl), the storage model file (.ssdl), and the mapping file (.msl). These files are either embedded as resources or copied to the output directory, depending on the value of the Metadata Artifact Processing property of the model. For more information, see How to: Edit Conceptual Model Properties (Entity Data Model Tools). For information about other values of the Build Action property, see File Properties.
  • Custom Tool
    When this property is set to EntityModelCodeGenerator (the default value) and the Code Generation Strategy is set to Default, the Entity Designer creates a source code file that contains classes that were generated from the conceptual model that is defined in the .edmx file. For more information, see Generated Code Overview (Entity Data Model Designer).
  • Custom Tool Namespace
    By default, this property is empty. When you provide a value, it will be used as the namespace for the code that is generated by the tool that is specified in the Custom Tool property. For more information, see Generated Code Overview (Entity Data Model Designer).

See Also

Concepts

Generated Code Overview (Entity Data Model Designer)

Other Resources

CSDL Specification