How to: Add an Existing .edmx File
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
Open or create the project to which you want to add the .edmx file.
Right-click the project name in Solution Explorer, point to Add, and then click Existing Item.
The Add Existing Item dialog box appears.
Browse to the .edmx file that corresponds to the model being added.
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.
Note: 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. Note: In Visual Basic projects, you must click the Show All Files button in Solution Explorer to see the source code file.
- References to the System.Data, System.Data.Entity, System.Core, System.Security, and System.Runtime.Serialization assemblies, if they do not already exist.
Add the connection string to the App.Config or Web.Config file, depending on the project type.
If your project does not already contain an App.Config or Web.Config file, you can add one by following these steps:
Right-click the project name in Solution Explorer, point to Add, and then click New Item.
The Add New Item dialog box appears.
Select Application Configuration File or Web Configuration File, depending on the project type.
- Right-click the project name in Solution Explorer, point to Add, and then click New Item.
In Solution Explorer, double-click the .edmx file to open it in the Entity Data Model Designer (Entity Designer).
Note: When you attempt to open an .edmx file that targets the .NET Framework version 3.5 (as indicated by the XML namespace http://schemas.microsoft.com/ado/2007/06/edmx), 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.