How to: Use the Object Data Model Wizard (Object Framework)

Source: Internet
Author: User
Document directory
  • Add an ADO. Net Object Data Model item Template
  • Generate an EDM File
  • For more information, see

This topic describes how to use the Entity Data Model Wizard to generate a ing file that defines the adventureworks sales Entity Data Model (EDM) and configure a Visual Studio project to use the Entity Framework. This model and configuration will be used in various Entity Framework topics related to the task.

The Object Data Model Wizard starts from Visual Studio 2008 Service Pack 1 (SP1) and becomes a component of Visual Studio. For more information, see the Object Data Model Wizard.

If you do not use the Object Data Model Wizard, You can manually create an EDM instance and configure the project to use the object framework. For more information, see How to: manually define an object data model (Entity Framework) and how to: manually configure an object framework project.

Add an ADO. Net Object Data Model item Template
  1. In"Project"Click"Add new project".

  2. In"Template"In the pane, select"ADO. Net Object Data Model".

  3. TypeAdventureworks. edmxAs the model name, and then click"Add".

    The first page of the "Object Data Model Wizard" is displayed.

Generate an EDM File
  1. In"Select model content"In the dialog box, select"Generate from database". Then, click"Next".

  2. Click"New Connection"Button.

  3. In"Connection property"In the dialog box, type the server name, select the authentication method, and for the database name, typeAdventureworksAnd then click"OK".

    "Select your data connection"The dialog box is updated with your database connection settings.

  4. Ensure"Save the object connection settings in APP. config :"The check box is selected and its value is setAdventureworksentities. Then, click"Next".

  5. In"Select database object"In the dialog box, clear all objects and expand"Table"And then select the following table object:

    • Address

    • Contact

    • Product

    • Salesorderheader

    • Salesorderdetail

  6. Click"Done"To complete the wizard.

    The Wizard will perform the following operations:

    • AddSystem. Data. Entity,System. runtime. serializationAndSystem. SecurityNamespace reference.

    • Generate the adventureworks. edmx file that defines EDM.

    • Create a source code file that contains the classes generated based on the EDM. You canSolution Resource Manager"To view the source code file.

    Note:

    In the Visual Basic Project, you must clickSolution Resource Manager"In"Show All Files"Button to view the source code file.

    • Create the app. config file.

  7. In the application code page, add the followingUsingStatement (in Visual BasicImports):

    Visual Basic

    Copy code

    Imports SystemImports System.LinqImports System.Collections.GenericImports System.TextImports System.DataImports System.Data.CommonImports System.Data.ObjectsImports System.Data.Objects.DataClasses' Prepend with the root namespace for the project.Imports AdventureWorksModel

    C #

    Copy code

    using System;using System.Linq;using System.Collections.Generic;using System.Text;using System.Data;using System.Data.Common;using System.Data.Objects;using System.Data.Objects.DataClasses;using AdventureWorksModel;
For more information, see concepts.

Quick Start (Entity Framework)

Other resources

ADO. NET Entity Data Model Designer
How to: create an object data model
ADO. NET Entity Data Model Designer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.