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 Generate Test Data for Databases by Using Data Generators.
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.
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.
To select tables to fill with data
Open or create a data generation plan. The data generation plan and the Data Generation Preview window appear in the Visual Studio designer.
If the Data Generation Preview window is not open, you can open it by opening the Data menu, pointing to Data Generation, and then clicking the window name. By default, the Data Generation Preview window is 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.
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.
Select and clear the check boxes in front of each table to specify the tables that you want to fill with data.
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:
Excluded from data generation
You can select the check box to include the table.
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.
(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.
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.