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

Prerequisites:

Lab Tasks:

  • 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.

  1. Start the Visual Studio 2017 Installer from your Start Menu. (This is separate from the Visual Studio IDE).

    The Visual Studio Products window displays. Visual Studio Enterprise 2017 is listed as installed, with two options: Update, or Launch.

  2. Click the Update button to get a list of workloads. Check the box next to the Data storage and processing workload box.

    The Modifying — Visual Studio window Workloads tab displays, with the Data storage and processing check box selected.

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.

  1. 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.

  2. 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.

    In the New Project dialog box, in the left pane, Templates is expanded, and SQL Server is selected. In the center pane, two options display: SQL Server Database project, and ReadyRoll SQL Server Database project.

  3. 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.

  4. Click OK to create the project. You might receive a license acknowledgement from Redgate Software to accept.

  5. After the project is created, you will have a new project in the Solution Explorer. This will look similar to the image below.

    In Solution Explorer, under Solution 'WideWorldImporters-RR, WideWorldImporters-RR is selected.

  6. 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.

    The ReadyRoll Core Edition pane displays. The left pane has a Welcome to ReadyRoll Core Edition message. The right pane has three steps: Create a new project (successfully completed as indicated by a green checkmark), Connect to Database, and Import Database.

  7. 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.

    On the WideWorldImporters-RR tab, Project Settings is selected in the left pane. In the right pane, in the Target platform drop-down list, SQL Server 2016 is selected.

  8. In the ReadyRoll window, click the Connect to database… (blue) button.

    Screenshot of the Connect to database button.

  9. 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.

    In Visual Studio, on the WideWorldImporters-RR tab, in the left pane, Debug is selected. A Connect dialog box with the History tab selected is open in front of it. Under Recent Connections, no connection history displays. Farther down, the Server Name field is set to (localdb)\ProjectsV13. Authentication is set to Windows Authentication, and Database Name is WideWorldImporters-RR.

  10. 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.

Screenshot of the Importing Database Status, which is at 4 percent.

  1. 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.

    First migration script

  2. 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.

    The ReadyRoll Pane now displays objects that have been imported. A message displays that a new script has been added to the Migrations project. Below, a list of Changes scripted displays their object type, owner, object name, action, and change summary.

  3. 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.

    The ReadyRoll Pane now displays a message that the script(s) have been successfully verified in the Migrations project.

  4. 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

  1. 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.

    In Team Explorer – Changes, under Changes, two changes display: 0001_20170607-105..., and WideWorldImporters..." At this time, the commit box is empty.

  2. 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.

    In Team Explorer – Changes, the Commit box now has the comment, “Initial database schema commit.” Below this, the Commit Staged button displays.

  3. 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.

    The Changes message displays with "Commit cef32647 created locally. Sync to share your changes with the server. The word Sync is a live link.

  4. 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)
  5. 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.

    Team Explorer – Synchronization displays, with fields populated for Team Services Domain, and Repository name. At the bottom is the Publish repository button.

  6. 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 "WideWorldImporters-RR was pushed" message displays. Next to it is a link to "See it on the web."

  7. A browser should open with your Visual Studio Team Services domain and project selected, on the Code tab. You should see your project listed. On the WideWorldImporers-RR webpage, on the Code tab, on the Files sub-tab, WideWorldImporters-RR folders and files display.

Summary

In this lab you completed the following tasks:

  • Altered an existing stored procedure
  • Added a new sequence
  • Checked in changes