How to create / open a DAC application in Visual Studio 2012?

I find it difficult to determine how to create or even open a DAC application with Visual Studio 2012. I am using SQL Server 2012. I have SSDT installed.

Creating from Visual Studio:

According to the online documentation, I should see a project template called "Application Tier Application", but all I see is a SQL Server database project. They are the same?

Creating from SSMS:

In the online video, the presenter uses the SSMS → Database → Right Click → Create Project menu item, and after the wizard, the VS project opens. I do not have this menu item, I have Tasks → Export as a data-level application. This creates a DACPAC file, but not a VS project, and I could not figure out how to open dacpac from VS.

+6
source share
1 answer

The purpose of DACPAC is to provide a portable representation of a database schema that can be used to deploy this schema to a database, import it into a database project in Visual Studio, and use features such as Schema Compare to examine the differences between different sources. Whenever you create a database project in Visual Studio, a .dacpac file is created, which can then be used to deploy the schema defined in this project to the database.

SSDT help is the best place for complete information, but I will give you a brief summary.

If you already have DACPAC, you can use it in VS in the following ways:

  • Import the diagram into the project by right-clicking on the project in the solution explorer and selecting "Import → Data Layer Application (* .dacpac)". Then select your dacpac and the content will be converted to SQL scripts and added to the project
  • Publish dacpac to the database by opening the SQL Server Object Explorer, going to the server, right-clicking on Databases and selecting "Publish data-level application ...". This will publish the contents of the DACPAC to the database on this server. You can update the database by right-clicking on the database in the "Databases" list. Note that if the SQL Server Object Explorer view is not open, you can choose View → SQL Server Object Explorer to make sure that it is displayed.

To create DACPAC in Visual Studio, you can

  • Create a project. This creates dacpac in the bin \ Debug directory (assuming you are creating Debug mode).
  • A snapshot of the project. This creates dacpac and saves it in the project. It is very useful to keep track of the instant versions of your database schema and to compare previous versions of the database with the latest definitions.
  • Right-click the database in SQL Server Object Explorer and select "Extract data-level application ...". This will create a dacpac that represents the contents of the database.

Finally, I'm not sure which video you watched, but maybe they showed a right-click on the database in the SQL Server Object Explorer and created the project from there. This is a very common way to start development using a database project, as often you will already have a database containing your schema. Typically, it will be best practice to develop using the project and use dacpacs (and possibly command line deployment tools like SqlPackage.exe) when deployed in different environments such as your production servers (again, dacpacs are great for transporting schema definitions and their deployment in different environments). Hope this helps answer your question!

+12
source

All Articles