How to: Separate Datasets and TableAdapters into Different Projects

Typed datasets have been enhanced so that the TableAdapters and dataset classes can be generated into separate projects. This enables you to quickly separate application layers and generate n-tier data applications.

The following procedure describes the process of using the Dataset Designer to generate dataset code into a project that is separate from the project that contains the generated TableAdapter code.

Separating Datasets and TableAdapters

When you separate dataset code from TableAdapter code, the project that will contain the dataset code must be located in the current solution. If this project is not located in the current solution, it will not be available in the DataSet Project list in the Properties window.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To separate the dataset into a different project

  1. Open a solution that contains a dataset (.xsd file).

    Note

    If the solution does not contain the project into which you want to separate your dataset code, create it, or add an existing project to the solution.

  2. Double-click a typed dataset file (an .xsd file) in Solution Explorer to open the dataset in the Dataset Designer.

  3. Click an empty area of the Dataset Designer.

  4. Locate the DataSet Project node in the Properties window.

  5. In the DataSet Project list, click the name of the project into which you want to generate the dataset code.

    After you click the project into which you want to generate the dataset code, the DataSet File property is populated with a default file name. You can change this name if you have to. Additionally, if you want to generate the dataset code into a specific directory, you can set the Project Folder property to the name of a folder.

    Note

    When you separate datasets and TableAdapters (by setting the DataSet Project property), existing partial dataset classes in the project will not be moved automatically. Existing dataset partial classes must be manually moved to the dataset project.

  6. Save the dataset.

    The dataset code is generated into the project selected in the DataSet Project property, and the TableAdapter code is generated into the current project.

By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file that is named DatasetName.Designer.vb (or DatasetName.Designer.cs) that contains the TableAdapter code. The project designated in the Dataset Project property has a file that is named DatasetName.DataSet.Designer.vb (or DatasetName.DataSet.Designer.cs) that contains the dataset code.

Note

With the dataset or TableAdapter project selected, click Show All Files in Solution Explorer to view the generated class file.

See Also

Tasks

Walkthrough: Creating an N-Tier Data Application

Concepts

N-Tier Data Application Overview

What's New in Data

Other Resources

Hierarchical Update

Accessing Data (Visual Studio)

ADO.NET