How to: create a LINQ to entities project in Visual Studio

Source: Internet
Author: User
Document directory
  • For. NET Framework 3.5
  • Create and reference the adventureworks sales model
  • For more information, see

For different types of language integration queries (LINQ) projects, some imported namespaces (Visual Basic) orUsingCommand (C #) and reference. The minimum requirement is to reference system. Core. dll and system. Data. entity. dll, as well asUsingCommand. You also need to reference the object data model (EDM) to be queried. The examples in the LINQ to entities section use the adventureworks sales model (EDM ).

If you want to upgrade a project from an earlier version of Visual Studio, you may have to manually provide these references related to LINQ. You may also have to manually set the project to for. NET Framework 3.5.

Note:

If you want to execute the generation from the command prompt, you must manually reference the drive:\ Program Files \ reference assemblies \ Microsoft \ framework \ v3.5.

For. NET Framework 3.5
  1. In Visual Studio 2008, create a new visual basic or C # project. Alternatively, you can open a visual basic or C # project created in Visual Studio 2005 and convert it to a Visual Studio 2008 project.

  2. In"Project"Click"Attribute".

    • For C # projects"Application"Property page"Target framework"Select ". NET Framework 3.5 ".

    • For visual basic projects"Compile"On the properties page, click"Advanced compilation options"And then"Target framework (All configurations )"Select ". NET Framework 3.5 ".

  3. In"Project"Click"Add reference".

  4. In"Add reference"In the dialog box, click". Net"Tab, from"Component name"Select system. core from the list, and then click"OK".

  5. For C # projectsSystem. LINQAndSystem. Data. ObjectsTheUsingCommand to add to the source code file or project.

    For visual basic projectsSystem. LINQAndSystem. Data. ObjectsTheImportsCommand to add to the source code file or project.

Create and reference the adventureworks sales model
  1. In"Project"Click"Add new project".

  2. In the template pane, select ADO. Net object data model ".

  3. In"Name"Box, typeAdvworksmodel. edmxAnd then click"Add".

  4. Select"Generate from database"And then click"Next".

  5. In"Select your data connection"Window, select an existing adventureworks connection from the list, or create a new connection to the SQL server instance that contains the adventureworks sample database.

  6. Save the object connection settings in APP. configAdventureworksentitiesAnd then click"Next".

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

    • Address (person)

    • Contact (person)

    • Product (production)

    • Salesorderdetail (sales)

    • Salesorderheader (sales)

  8. Name the model namespaceAdventureworksmodelAnd then click"Done".

  9. For C # projectsUsingStatement to the source file.

    For visual basic projectsImportsStatement to the source file.

For more information, see concepts.

Overview of LINQ to entities
Examples of LINQ to entities

Related Article

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.