Share via


Overview of Generating Data

You can use Microsoft Visual Studio Team Edition for Database Professionals to fill a test database with test data. You can generate data that is appropriate for the schema of the database but unrelated to the production data. You can then create and run unit tests that give meaningful results about the database without using production data. This approach can help you if it is important that you protect the privacy or security of the production data. This topic provides an overview of how you can generate data in Team Edition for Database Professionals.

Generating Data

To generate data, you must follow these steps:

  1. Create a data generation plan. For more information, see How to: Create Data Generation Plans.

  2. Select the tables to fill with data, and specify how much data to generate for each table. In some cases, you might need to generate data for some tables only. For more information, see How to: Specify Tables for Data Generation and How to: Specify the Number of Rows to Generate.

  3. Select the columns to fill with data, and configure the settings for each column. This information is the core of the data generation plan. By selecting data generators and setting the properties for each column, you control exactly what data is generated to fill each column. For more information, see How to: Specify Columns for Data Generation and Specifying Details of Data Generation for a Column.

  4. Run the data generation plan to generate the data. For more information, see How to: Run a Data Generation Plan to Generate Data.

Data Generators

Team Edition for Database Professionals includes several built-in standard data generators for generating different kinds of data. For example, the integer data generator generates random integer values, the string generator generates random strings, and the regular expression generator generates strings that match a pattern that you specify. For more information and the complete list of standard data generators, see Standard Data Generator Types and Using Standard Generators.

Custom Data Generators

You can extend the data generation capabilities of Visual Studio Team Edition for Database Professionals by creating custom data generators or by extending standard data generators. If you have a business rule that the standard data generators cannot satisfy, you can create a custom data generator. For example, if you have a column that has a check constraint that references another column, you might want to create a custom data generator. You can then use the custom generator to fill that column with data. For more information, see Creating Custom Generators.

Team Edition for Database Professionals includes an extensibility API that you can use to create custom data generators. For more information, see Microsoft.VisualStudio.TeamSystem.Data.DataGenerator.

Data Generation Plans and Schema Changes

When you create a data generation plan in a database project, the plan is based on the database schema of the project. If you create a data generation plan and then the schema of the database project changes, you are prompted to update the plan. This behavior occurs in the following cases:

  • You create a data generation plan in a database project that does not have a schema yet. You then import a schema into the database project.

  • You create a data generation plan in a database project that has a schema, and then the schema changes.

In both cases, you are prompted to update the data generation plan when you open it or when it becomes the active document. If you do not update the data generation plan based on the schema changes, you cannot continue to edit the plan. You can close and reopen the data generation plan to display the prompt again.

Data Generation Plans in a Team Environment

A data generation plan is an XML file that contains information about the database schema and configuration information that controls the data generation for each column in each selected table. A data generation plan for a modest database that contains about 40 tables can be about 8 MB and more than 100,000 lines long.

You cannot automatically merge changes to a .dgen file by using Team Foundation source control or Visual SourceSafe, and manually merging large XML files is difficult and prone to errors. You can minimize problems related to your data generation planby using exclusive checkout on your data generation plan when you have to make changes.

Data Generation Plans and Unit Tests

You can use database unit tests to verify that changes that you make to database objects do not break existing functionality by introducing errors. Database unit tests complement the software unit tests that software developers create. For more information, see Overview of Database Unit Testing.

To run a database unit test, you must have meaningful test data. You can create a data generation plan that creates meaningful data and then link it to a unit test. Each time that you run the unit test, the data generation plan is run first to create the data for the test. You can see an example of this in Walkthrough: Creating and Running a Database Unit Test.

Security

For more information, see Security of Data Generators.

See Also

Concepts

Troubleshooting Data Generation Issues

Other Resources

Data Generation Plans
Generating Data with Data Generators
Options (Database Tools/Data Generator/General)
Options (Database Tools/Data Generator/Default Generators)