How to: Create Custom Data Generators
Custom data generators are components that the Data Generator feature uses to generate data in data generation plans. Although the Data Generator feature supplies several preset generators, you might want to create custom generators to suit your particular needs.
This topic describes how to create a custom data generator using typical extensibility. Typical extensibility is the recommended method to use most of the time. You can also use other methods to create custom data generators, including declarative extensibility, aggregation extensibility, and base extensibility. For more information, see An Overview of Data Generator Extensibility.
To create a custom data generator
Create a class library project.
In Solution Explorer, right-click the project, and then click Add Reference.
The Add Reference dialog box appears.
Click the .NET tab. In the Component Name list, click Microsoft.Data.Schema, and then click OK.
(Optional, Visual Basic only) In Solution Explorer, click the Show All Files button, and expand the References node to verify the new reference.
At the top of the Code window, before the class declaration, add the following line of code:
Rename the class from Class1 to the name that you want.
By default, the name that you give your class is the name that will appear in the list in the Generator column in the Column Details window. You should specify a name that does not conflict with either the name of a standard generator or the name of another custom generator. For more information, see Considerations for Custom Data Generators.
Specify that your class inherits from Generator, as shown in the following example:
(Optional) Add the GeneratorStylesAttribute to the class declaration.
If you want your custom data generator to be the default data generator for a type of column, it must produce unique values, and you must add the GeneratorStylesAttribute to the class. For more information, see How to: Change the Default Generator for a Column Type.
<GeneratorStyles(DesignerStyles:=GeneratorDesignerStyles.CanProduceUniqueValues)> _ Public Class TestGenerator Inherits Generator End Class
(Optional) Add the GeneratorAttribute to the class declaration.
Add this attribute to the class declaration only if you want to specify a custom designer type for your custom data generator. If you do not want to specify a custom designer type, omit this attribute, and the default designer will be used automatically.
<Generator(GetType(CustomDesignerType))> _ Public Class TestGenerator Inherits Generator End Class
Add at least one output property. For more information, see How to: Add Output Properties to a Data Generator.
If needed, add input properties. For more information, see How to: Add Input Properties to a Data Generator.
Sign the assembly with a strong name. For more information, see Walkthrough: Creating a Custom Data Generator.
Build the solution.