How to: Define a Data Generation Plan that Reuses Data from Another Database
This topic applies to:
Visual Studio Ultimate |
Visual Studio Premium |
Visual Studio 2010 Professional |
Visual Studio Express |
---|---|---|---|
To generate data, you must create and run a data generation plan. You can define a data generation plan that extracts data from another database. The data generation plan contains the information about which tables and columns that you want to fill with data. It also contains details about what kind of data that you want to put in each column, and how much. The data generation plan is saved as a file in the database project that you can edit and reuse. For more information, see Generating Test Data for Databases by Using Data Generators.
To define a data generation plan that reuses data
Open or create a database project or data-tier application component (DAC) project.
Note
If you create a data generation plan in a project that does not have a schema yet, the plan will be empty. If you import a schema into the project after you have created the plan, you are prompted to decide whether to update the plan based on the new schema.
Right-click the Data Generation Plans node in Solution Explorer, point to Add, and then click Data Generation Plan.
You can also click a folder in Solution Explorer, open the Project menu, and click Add New Item.
In the Installed Templates pane, click Data Generation Plan.
In the details pane, click Data Transform Plan.
In the Name box, type the name that you want to give the data generation plan.
Click Add.
The Data Transform Plan dialog box appears.
In Source connection string, click the connection that corresponds to the database from which you want to reuse data. If the connection does not exist, you can create it by clicking New Connection. For more information, see How to: Create a Database Connection.
You can optionally customize the plan generation options. For more information, see the following procedure.
Click OK.
The Data Transform Plan Status dialog box appears and the data generation plan is created.
Click Close.
Your data generation plan opens. You might want customize the plan if the database that you are reusing contains tables or columns with sensitive information. For more information, see Specify Details of Data Generation for a Column.
To customize options for the Data Transform Plan
If you want each table to have the default number of rows as specified in Tools, Options, clear the Set the number of rows to generate to be equal to the number of rows in the source database check box.
If you want the foreign key generator to generate foreign keys instead of copying them from the source database, clear the Replace foreign key generator check box.
If you want to replace the foreign key generator and all foreign keys were generated by your application and not by the database, select the Replace foreign key generator check box and select the Replace all foreign key generators with foreign keys from the target database radio button.
If you want to replace only foreign keys that do not reference a value that was generated by the database, select the Replace foreign key generator check box and select the Use foreign keys from the source database when the foreign key does not reference a column with database-generated values radio button.
If you want to allow some number of tables to fail data generation before you stop the data generation process, enter a nonzero value in Error thresholds.
See Also
Tasks
Walkthrough: Creating and Running a Data Generation Plan