How to: Add an Existing .edmx File

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic describes how to add an existing .edmx file to a Visual Studio project. The .edmx file contains conceptual model as well as storage model and mapping information. For more information, see .edmx File Overview.

The procedure outlined in this topic assumes that the database already exists (or will be created) for the model being added. For more information, see How to: Generate a Database from a Conceptual Model.

To add an existing .edmx file to a Visual Studio Project

  1. Open or create the project to which you want to add the .edmx file.

  2. Right-click the project name in Solution Explorer, point to Add, and then click Existing Item.

    The Add Existing Item dialog box appears.

  3. Browse to the .edmx file that corresponds to the model being added.

  4. Select the .edmx file to be added, and then click Add.

    The .edmx file is added to the project. The following are also added to the project:

    • References to the System.Data, System.Data.Entity, System.Core, System.Security, and System.Runtime.Serialization assemblies, if they do not already exist.

    • A source code file that contains classes that were generated from the conceptual model. You can view the source code file by expanding the .edmx node in Solution Explorer.

    The source code file is generated from the .edmx file. Any manual changes to the source code file are overwritten when the corresponding .edmx file changes.

    In Visual Basic projects, you must click the Show All Files button in Solution Explorer to see the source code file.

  5. Add the connection string to the App.Config or Web.Config file, depending on the project type.

    For information about connection string format, see Connection Strings and How to: Define the Connection String.

    If your project does not already contain an App.Config or Web.Config file, you can add one by following these steps:

    1. Right-click the project name in Solution Explorer, point to Add, and then click New Item.

      The Add New Item dialog box appears.

    2. Select Application Configuration File or Web Configuration File, depending on the project type.

    3. Click Add.

  6. In Solution Explorer, double-click the .edmx file to open it in the Entity Data Model Designer (Entity Designer).

    When you attempt to open an .edmx file that targets the .NET Framework version 3.5 (as indicated by the XML namespace, the Entity Designer prompts you to update the version before opening it. When you click modify, the Entity Designer will update the version (by updating the XML namespace) and open the file.

See Also