Setup ReadyRoll in Visual Studio
In this lab, we will set up ReadyRoll in Visual Studio 2017 Enterprise. We will also import our database and make an initial commit to our Visual Studio Team Services repository.
DevOps MPP Course Source
- This lab is used in course DevOps200.6x: DevOps for Databses - Module 1.
- Visual Studio 2017 Enterprise (or evaluation), patched to SP1 on LocalDB
- Internet access
- LocalDB installed with the sample databases by completing the earlier lab Setup WideWorldImporters sample database Development Environment
- Add ReadyRoll to Visual Studio
- Create a new ReadyRoll project
- Make an initial commit to version control
Estimated Lab Time:
- approx. 30 minutes
Task 1: Add ReadyRoll to Visual Studio
Include the Data storage and processing workload to add the ReadyRoll features to your Visual Studio installation.
If the Data storage and processing workload is installed in Visual Studio, skip this section. If you have already completed Lab 1.3, you will have these tools installed.
Start the Visual Studio 2017 Installer from your Start Menu. (This is separate from the Visual Studio IDE).
Click the Update button to get a list of workloads. Check the box next to the Data storage and processing workload box.
This process is described in this article: Modify Visual Studio 2017 by adding or removing workloads and components
Task 2: Create a new ReadyRoll project
Use ReadyRoll to create a new project and connect this to your database.
Start Visual Studio 2017. If you have not signed into Visual Studio.com, you might receive a dialog to do so. Use the credentials for your VisualStudio.com account.
From the File menu, click New, then click Project (or click CTRL+Shift+N). You will receive a new project dialog. click the SQL Server template on the left and you should be presented with two options in the middle pane.
Select the ReadyRoll SQL Server Database Project, and type and enter WideWorldImporters-RR as the project name. Ensure the Add to Source Control check box is selected. Change the folder if you want to store this in a different location.
Click OK to create the project. You might receive a license acknowledgement from Redgate Software to accept.
After the project is created, you will have a new project in the Solution Explorer. This will look similar to the image below.
There should also be a ReadyRoll Core Edition pane at the bottom of the Visual Studio window. If this is not visible, from the ReadyRoll menu, click ReadyRoll.
Right-click the project file and choose Properties. Select the Project Settings tab and ensure that the Target platform is SQL Server 2016. On the toolbar, click Save Selected Items, then close the tab.
In the ReadyRoll window, click the Connect to database… (blue) button.
This will open the project properties in the background with the Debug pane preselected and should open the Connect dialog, as shown below. Enter the Server Name and Database Name as shown. Click Test Connection, ensure it succeeds, then click OK.
Click Import Database in the ReadyRoll dialog.
This will read the schema from the WideWorldImporters-RR database and create an initial migration script with all the schema.
![Screenshot of the Import Database button.](../assets/setupreadyrollinvs-jan2018\Lab1.4_Image9.jpg)
As this proceeds, we will see a progress status.
After this is complete, the first migration script, named 001_xxxx.sql, will open. The name is numerically incremented based on previous scripts in this folder, the date and time, and then username, so the name of your script will be different than the one shown in the image.
In the ReadyRoll pane, a list of items that have been imported is shown, the name of the script, and then a request to refresh and verify the scripts.
Click Refresh to have the script actually run against our Shadow database and verify that the accuracy of the code. When that completes, the ReadyRoll pane should show the code as verified.
Close the migration script window.
Task 3: Make an initial commit to version control
Publish our project to your VSTS project.
In this section, we want to commit our code to the VSTS project from the earlier Lab task Setup VSTS for Database Development
Open the Team Explorer toolbar (or select it from beside Solution Explorer if it is already open), then click Changes. You should see a list of changes that also include the various Visual Studio project items.
Note: If prompted to connect to Git, do so at this point.
Enter a commit message in the yellow box. I typically use “Initial Commit” for the first set of code. After you have entered this, click Commit Staged.
After the commit is complete, you should see a message that confirms that. Notice that there is a sync link in the message. Click this link.
This will bring you to the synchronization dialog in Team Explorer, which allows you to publish this to a VSTS repo. Click the Publish Git Repo button under Push to Visual Studio Team Services.
![In Team Explorer – Synchronization, under Push WideWorldImporters-RR, the message “Backup and share your code. Publish it to a Git service” displays. Below are two options: Push to Visual Studio Team Services, and Push to Remote Repository. Both options have a Publish Git Repo button.](../assets/setupreadyrollinvs-jan2018\Lab1.4_Image18.jpg)
In the next dialog, you should see your account along with the Team Services domain filled in. If not, you might need to log in to your VSTS account from Visual Studio. In the upper right corner of Visual Studio, there is a sign-in link. Then click Publish repository.
After this is complete, you should see a message at the top of Team Explorer that confirms that the repo was pushed. Click See it on the web.
A browser should open with your Visual Studio Team Services domain and project selected, on the Code tab. You should see your project listed.
In this lab you completed the following tasks:
- Altered an existing stored procedure
- Added a new sequence
- Checked in changes