Data Generator for SQL Server can be directly involved in the Continuous Integration (CI) process via the PowerShell cmdlets that can automate the generation of realistic test data during database development.
The guide covers the following topics:
To start using Data Generator in the DevOps process, make sure that:
Note
By default, PowerShell is installed on Windows 8, 8.1, 10, and 11. For other versions, download PowerShell from the Microsoft official download center page.
To check the current version of PowerShell, open WindowsPowerShell and execute the
$PSVersionTable.PSVersion
command. In the Major column, you can see the version currently installed on your computer.
dbForge DevOps Automation for SQL Server is supplied as part of dbForge SQL Tools (Professional version) and automatically includes dbForge DevOps Automation PowerShell for SQL Server.
To install dbForge DevOps Automation PowerShell for SQL Server:
1. Go to the download page and click Get for free.
2. On the Devart Identity Server page, sign in to your account and then click Download. If you don’t have a Devart account, you need to sign up.
3. After the download is complete, navigate to the folder with the downloads and run the sqltoolspro.exe file to install dbForge DevOps Automation PowerShell for SQL Server.
4. In the dbForge SQL Tools Professional installer, click Install.
Note
Prior to installing the tool, make sure that SSMS instances are closed.
5. On the Select Products page, make sure that the dbForge DevOps Automation PowerShell for SQL Server check box is selected. Then, click Next.
Note
If you have not installed Data Generator for SQL Server yet, in this step select the Data Generator for SQL Server check box as well.
6. After the installation is complete, click Finish. The Devart.DbForge.DevOpsAutomation.SqlServer module with a set of cmdlets appears in Windows PowerShell.
You can check the full list of requirements to run dbForge DevOps Automation on the Requirements and Compatibility page.
To create a data generation project:
1. Open Data Generator on your computer and click .
2. In Data Generation Wizard, choose the required Connection and Database. Click Open.
3. In the project window that opens, choose the tables to be populated and configure all the necessary settings.
4. Either click the button or press Ctrl+S.
5. Choose the path to save your project. You will use this path in a PowerShell script later.
The Invoke-DevartPopulate cmdlet populates a database with sample data.
To generate data using PowerShell cmdlet:
1. Run Windows PowerShell on your computer.
2. In Windows PowerShell, execute the PowerShell script to run unit tests.
# Defining variables
$ServerName = "JORDANS\SQL2019ENT"
$DatabaseName = "AdventureWorks2019"
$DataGeneratorProject = "D:\data_generator\AdventureWorks2019.dgen"
# Create a database connection
Write-Host "Creating a database connection..." -ForegroundColor Cyan
$Connection = New-DevartSqlDatabaseConnection -Server $ServerName -database $DatabaseName -UserName SA
# Populate a database
Write-Host "Populating a database..." -ForegroundColor Cyan
Invoke-DevartPopulate -DataGeneratorProject $DataGeneratorProject -Connection $Connection
Parameters used in the script
Parameter | Description |
---|---|
-Connection | Connection to the server where the database is located. |
-Server | The server we are connecting to. |
-Database | The database we are working with. |
-UserName | The username that is used to connect to the SQL server. |
-DataGeneratorProject | Path to the output report file with the test results. |
-ForegroundColor | Specifies the color of the output. |
Watch the video tutorial to learn how to use dbForge Data Generator in DevOps process: