Search code examples
tfsdatabase-project

Sync references with TFs in VS database projects


In db projects, when you add a database dac-pac for example as a reference use in a view to reference a third party database, that seems to be valid only for your local copy.

In VS 2015 I can;t seem to find how you add that as a build so that it syncs and compares with the version you store in source control.

If I check out a team project, create a view referencing a third party DB, create a dac-pac for that DB, add it as a database reference, save, build, check in, by default that reference isn't checked in to the server for another developer to check out in the latest version and therefor they will get reference errors.

Does anyone know how to sync these? I can't find an option to do so!

Also, it would be nice to be able to edit the dam things, For example if they are on a different server you must define that. But say the server changes, you can only edit it in your publish profile, however if you do that but someone else doesn't it will flag as a change for them.


Solution

  • You'd better add the .dacpac file to TFS version control. When others check out from other machines, get down the .dacpac file together with that db project.

    Make sure that when other check out that file and the db project to their local machine, the relative path between them are same with that in your environment. Actually, in the .sqlproj file of your db project, it has defined the relationship.

    For example, I put the .dacpac file under a folder named "DACPAC" and this folder is at the same level of my solution folder.

    enter image description here

    In the .sqlproj file:

    <ArtifactReference Include="..\..\DACPAC\TestDB.dacpac">
          <HintPath>..\..\DACPAC\TestDB.dacpac</HintPath>
            ......
     </ArtifactReference>
    

    Note: The "..\" mean go to the uplevel path from where the .sqlproj at. It has 2 "..\", so go 2 uplevels.