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:
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!!