Using DACPACS to version Database

Chris Swainson 21 Reputation points
2022-08-09T18:45:43.567+00:00

Hi All,

I was hoping to use DACPACs as a convenient way of both upgrading databases and versioning them.

If I use a DACPAC with a version number added during it's generation and use it to upgrade the data-tier application, a subsequent select query from [sysdac_instances] shows the [type_version] number has been updated. However, if I subsequently detach the database and attach a copy of it that has not been through the upgrade process, the same query from [sysdac_instances] gives me the same version number.

Thus the DACPAC version number is a function of the server and not the database. If I am attaching and detaching databases with the same name I have no easy way to figure out which have been upgraded and which haven't.

Am I missing something?

Thanks,

Chris

SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. YufeiShao-msft 7,146 Reputation points
    2022-08-10T08:35:32.957+00:00

    Hi @Chris Swainson ,

    You can try to use with SSDT

    There is a way to as user-defined extended properties:
    https://dba.stackexchange.com/questions/131018/howto-create-useful-dacpac-versioning-along-with-ssdt-deployment

    https://www.techrepublic.com/article/auto-deploy-and-version-your-sql-server-database-with-ssdt/


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Tom Phillips 17,771 Reputation points
    2022-08-09T20:19:23.29+00:00

    The best thing to do is to create an "extended property" on the database with your version in it. Then it goes with the database.

    See:
    https://www.mssqltips.com/sqlservertip/5384/working-with-sql-server-extended-properties/

    1 person found this answer helpful.

  2. Chris Swainson 21 Reputation points
    2022-08-11T18:48:27.747+00:00

    Thanks for your swift replies.

    I'll try the proposed solution using extended properties.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.