title: Upgrading DACPACs with DACFx 3.0 API - How to inspect current DAC version of an existing database?
body: <p>I am currently rewriting my team's database deployment Powershell script to use DACFx 3.0 API instead of 2.0. I've managed to get the DACPAC upgrade to work successfully, using the new <code>Microsoft.SqlServer.Dac.DacServices</code> controller class.</p>
  
  <p>The only problem that remains is: how can I grab the current DACPAC version number off an existing database? </p>
  
  <p>As part of our deployment script, we're comparing this to the DACPAC version that we are upgrading to, to determine whether a deployment is necessary. This is also used to decide whether to run the database-related tests, so this way we cut down a significant amount of time on our builds.</p>
  
  <p>The old DacFx2.0 API lives in the <code>Microsoft.SqlServer.Management.Dac</code> namespace, so in the old Powershell script we simply created a <code>DacStore</code> object from the database connection and get the Version property off it:</p>
  
  <p><strong>OUR OLD POWERSHELL SCRIPT</strong></p>
  
  <pre><code>$dacStore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($serverConnection)
  Write-Host "The following data-tier applications (instances) exist in the DAC store:"
  foreach($dacInstance in $dacStore.DacInstances) 
  {
      Write-Host Instance Name: $dacInstance.Name
      Write-Host DAC Type Application Name: $dacInstance.Type.Name
      Write-Host DAC Type Version: $dacInstance.Type.Version &lt;--- **** this is what I need ****
  }
  ...
  </code></pre>
  
  <p>The issue now in 3.0, the API lives in the <code>Microsoft.SqlServer.Dac</code> namespace, and "Instead of using the <code>DacStore</code> and <code>DacExtractionUnit</code> classes from previous versions, most everything has been refactored into the all-new <code>DacServices</code> controller class. (<a href="http://www.sqlskills.com/blogs/bobb/dacfx-3-0-the-new-programming-api/" rel="nofollow">src</a>)"</p>
  
  <p><strong>I haven't been able to find an equivalent of <code>DacStore</code> in the <code>DacServices</code> class yet, so as of right now I don't know how to retrieve the current DAC version.</strong> I've tried searching through MSDN documentations but all their Powershell sections still referenced the old DACFx2.0 API. (example: <a href="http://technet.microsoft.com/en-us/library/ee210569.aspx" rel="nofollow">here</a>).</p>
  
  <p>If anyone could help me that would be greatly appreciated. Thanks!</p>