Export (0) Print
Expand All

How to: Manually Configure an Entity Framework Project

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

If you use the Entity Data Model Wizard in a Visual Studio project, the wizard automatically generates an .edmx file and configures the project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard. You can also manually configure a Visual Studio project to use the Entity Framework. Do this if you have manually defined the model and mapping files or defined them by using the EDM Generator (EdmGen.exe) utility. 

The examples in this topic use the model and mapping files for the AdventureWorks Sales model. The AdventureWorks Sales Model is used throughout the task-related topics in the Entity Framework documentation.

To configure a Visual Studio project to use the AdventureWorks Sales Model

  1. In Solution Explorer, add assembly references to System.Data.Entity.dll and System.Runtime.Serialization.dll.

  2. Add the following model and mapping files to the project:

    • AdventureWorks.csdl

    • AdventureWorks.msl

    • AdventureWorks.ssdl

    For information about creating these files, see How to: Manually Define the Model and Mapping Files.

  3. Select the three files you just added to the project directory. On the Project menu, click Include In Project.

  4. Select the three files you added to the project directory. On the Project menu, click Properties.

  5. In the Properties pane, set Copy to Output Directory to Copy if newer.

  6. Open the project's application configuration file (App.config) and add the following connection string:

    If your project does not have an application configuration file, you can add one by selecting Add New Item from the Project menu, selecting the General category, selecting Application Configuration File, and then clicking Add.

  7. At the command prompt in your project directory, run the appropriate command for your project (with line breaks removed):

    • For C#:

    • For Visual Basic:

    This generates an object layer file in either C# or Visual Basic that is based on the conceptual model.

  8. Add the object-layer file generated in the previous step to your project.

  9. In the code page for your application, add the following using statements (Imports in Visual Basic):

See Also

Show:
© 2014 Microsoft