Separate datasets and TableAdapters into different projects
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
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.
Separate datasets and TableAdapters
When you separate dataset code from TableAdapter code, the project that contains the dataset code must be located in the current solution. If this project is not located in the current solution, it won't 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 this article. You may be using a different edition of Visual Studio or different environment settings. For more information, see Personalize the IDE.
To separate the dataset into a different project
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 the project, or add an existing project to the solution.
Double-click a typed dataset file (an .xsd file) in Solution Explorer to open the dataset in the Dataset Designer.
Select an empty area of the Dataset Designer.
In the Properties window, locate the DataSet Project node.
In the DataSet Project list, select the name of the project into which you want to generate the dataset code.
After you select 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 necessary. 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 won't be moved automatically. Existing partial dataset classes must be moved manually to the dataset project.
Save the dataset.
The dataset code is generated into the selected project 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 named DatasetName.Designer.vb (or DatasetName.Designer.cs) that contains the TableAdapter code. The project that's designated in the Dataset Project property has a file named DatasetName.DataSet.Designer.vb (or DatasetName.DataSet.Designer.cs) that contains the dataset code.
Note
To view the generated class file, select the dataset or TableAdapter project. Then, in Solution Explorer, select Show All Files.