Lesson 4: Editing a DAC in Visual Studio

In this lesson, you will add a table to the sample DAC project you created in Lesson 1, and then build the DAC package used to upgrade the deployed DAC in the next lesson. All of the steps in this lesson are performed in Visual Studio.

Procedures

Open the SampleDAC Project in Visual Studio

  1. Open Microsoft Visual Studio.

  2. On the File menu, point to Open, and click Project/Solution….

    The.Open Project dialog appears.

  3. Expand the SampleDAC folder, click the SampleDac.sln file, and then click Open.

    You have opened the SampleDAC solution and project.

    Next, you will add a second table to the project.

Adding a Table and Building the DAC

Now that the SampleDAC project is open, the following steps illustrate adding objects to the project, then building the DAC package.

To add a table to the project

  1. In Schema View, expand the SampleDAC node, expand the Schemas node, and expand the node for the dbo schema.

  2. Right click the Tables node, select Add, and then Table.

  3. In the Add New Item dialog, ensure Table template is selected, and change the value in the Name box at the bottom of the dialog to read SalesAssociate. Click the Add button. A Transact-SQL Editor window is now open for a file named SalesAssociate.table.sql.

  4. In the Transact-SQL Editor window, edit the CREATE TABLE statement to read:

    CREATE TABLE [dbo].[SalesAssociate]
    (
        [EmployeeID]   INT           PRIMARY KEY,
        [EmployeeName] NVARCHAR(40)  NOT NULL,
        [YTDOrders]    INT           NOT NULL,
        [YTDSales]     INT           NOT NULL
    );
    
  5. Close the Transact-SQL Editor, saving your changes. In Schema View you should now see a SalesAssociate table under the dbo node. In Solution Explorer you should now see a SalesAssociate.table.sql file.

    You have now added a table to the SampleDAC project, and can build the project.

To build the project

  1. In Solution Explorer, right-click the SampleDAC node, and select Build.

  2. In the Output window, review the report of the build actions. One of the items reported is the path and name of the SampleDAC.dacpac file created by the build.

  3. If the instance of the Database Engine where you will upgrade the DAC is on a separate computer, copy the SampleDAC.dacpac file to a location that can be accessed from the other computer.

    You have now built the SampleDAC project. You can hand off the .dacpac file to a developer or database administrator, who can then use the Import Data-tier Application Wizard in SQL Server Management Studio to deploy the DAC to an instance of the database engine

Next Steps

You have successfully added a new table in the SampleDAC project and built a new version of the DAC package. Next, you will use the package to upgrade the DAC you deployed in Lesson 2. See Lesson 5: Upgrading a Data-tier Application.