How to: Specify Tables for Data Generation

To generate data, you must create and run a data generation plan. The data generation plan contains the information about which tables and columns you want to fill with data. For more information, see Data Generation Plans.

The following are two important restrictions about what tables you can specify for data generation:

  • Some tables have foreign keys that reference columns in other tables. If you want to generate data for a table with foreign keys, you must also generate data for the tables that are referenced by the key.

  • Some tables have triggers that forbid deletes. If you try to delete rows from such a table, the trigger rolls back the delete. You cannot generate data normally for such a table, or for a table that references such a table. For example, you cannot generate data normally for the Employee table on the AdventureWorks database. For more information, see Troubleshooting Data Generation Issues.

Before you can specify the tables that you want to fill with data, you must open or create a data generation plan. For more information, see How to: Create Data Generation Plans.

Note

If you create a data generation plan in a database project that does not have a schema yet, the data generation plan will be empty. If you import a schema into the database project after you have created the data generation plan, you are prompted to decide whether to update the data generation plan based on the schema. For more information, see Overview of Generating Data.

To select tables to fill with data

  1. Open or create a data generation plan. The data generation plan, the Data Generation Preview window, and the Column Details window all appear in the Visual Studio designer.

    Tip

    If the Column Details and Data Generation Preview windows are not open, you can open them by opening the Data menu, pointing to Data Generation, and then clicking the window name. By default, the Data Generation Preview window and the Column Details window are docked and tabbed at the bottom of the data generation plan window. To expand your view, click the window and then click Tabbed Document on the Window menu. You can also right-click in the title bar and then click Tabbed Document.

  2. Click the data generation plan window.

    All the tables in the schema are listed in the data generation plan. By default, all the tables are selected when you first create a data generation plan.

  3. Select and clear the check boxes in front of each table to specify the tables that you want to fill with data.

    Note

    You can select or clear all the tables by using the Include All Tables In Data Generation and Exclude All Tables From Data Generation commands. You can access these commands by right-clicking the data generation plan window or on the Data menu, point to Data Generator.

    You will not be able to clear the check boxes for tables that are referenced by foreign keys in other included tables. The check boxes can have one of the following states:

    State Tooltip Notes

    Unchecked

    Excluded from data generation

    You can select the check box to include the table.

    Checked

    Included in data generation

    You can clear the check box to exclude the table.

    Checked and Dimmed

    Included in data generation (because of foreign key reference)

    You can select the check box to include the table. You cannot clear the check box. If all the tables that reference the table are excluded, the check box is cleared automatically.

  4. (Optional) Specify information in the Rows to Insert, Related Table, and Ratio to Related Table columns. For more information, see How to: Specify the Number of Rows to Generate.

  5. On the File menu, click Save.

    Now that you have specified what tables you want to include, you can specify what columns you want to include. For more information, see How to: Specify Columns for Data Generation.

See Also

Tasks

How to: Run a Data Generation Plan to Generate Data
Specifying Details of Data Generation for a Column
Walkthrough: Creating and Running a Data Generation Plan

Other Resources

Data Generator Walkthroughs