0

I was trying to implement an SDK-styled .sqlproj project on VSCode (or VisualStudio if possible) on which you could get the Nuget packages with just a .dacpac file from an Artifact Feed on Azure Devops and use the tables of that .dacpac file in SQL Code, querying against it. I´ve taken a look at this recent Microsoft documentation on this but it hasn´t helped much:

https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/sql-database-project-extension-sdk-style-projects?view=sql-server-ver16

I have a .dacpac file in the directory where the .sqlproj file is and I followed these steps:

  • 1. Connect to the Azure Artifact Feed by creating the nuget.config file in the .sqlproj file directory and executing ./nuget.exe restore.
  • 2. Created a Nuget package with the .dacpac file inside, basically by creating a basic nuspec file and in the files tag of it set the ./test.dacpac file and using commands ./nuget.exe spec and ./nuget.exe pack. https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package
  • 3. Push the .nupkg Nuget Package to the Artifact Feed by using ./nuget.exe push command.

After that, I have basically two main doubts:

  • How can I reference or query the tables inside the .dacpac file in a SQL Code? Not referring to get data from it like SELECT * ..., just having the reference so I can code sql in my sqlproj having a reference to the dacpac, and then publish it to the server where the data is
  • How can I even get the package from the artifact feed into my local project on VSCode/VS?

I am using the following:

  • VS 2019 with .NET 4.6 Framework (if required, we can try with VS2022 and .NET6.0).
  • SQL Server 2014 Management Studio (if required, we can try with 2019).
  • VSCode 1.78.

If there are any doubts with the question or the question is duplicated, don´t hesitate to comment it please.

Have a nice day and thanks in advance!!

1 Answers1

0

How can I even get the package from the artifact feed into my local project on VSCode/VS?

You don't. You get the .sqlproj from your DevOps Git repo during development.

The output of a .sqlproj is a .dacpac artifact which you deploy with pipeline, eg Azure SQL database deployment or with the sqlpackage utility.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • Hi! I have configured that and I think it works, however I still can´t use the reference to the nuget package with the .dacpac inside within my SQL code. It is basically the first doubt of the two I mentioned, and main one I have . Any help you can provide me on that? Thanks in advance! – martilux2580 May 23 '23 at 07:09
  • I don’t understand what you are trying to accomplish. Why would you reference a nuget package from SQL code? – David Browne - Microsoft May 23 '23 at 10:51
  • What I want to reference on my SQL Code are the tables inside the .dacpac file that is inside the NuGet package reference that is inside the .sqlproj file of my local project. If it is still confusing, don´t hesitate to comment again. I am following this documentation: https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/sql-database-project-extension-sdk-style-projects?view=sql-server-ver16#package-references – martilux2580 May 23 '23 at 11:54