title: TFS Build: Can't connect to the Database
body: <p>I'm trying to set up TFS build to deploy to my SQL Server Express instance but MSBuild keeps failing with: </p>
  
  <blockquote>
    <p>C:\Builds\1\portal\Deploy to Portal_Dev\bin\DB.publish.sql: Unable to connect to master or target server 'Portal_Deploy_Dev'. You must have a user with the same password in master or target server 'Portal_Deploy_Dev'.</p>
  </blockquote>
  
  <p>This is the publishing file: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;IncludeCompositeObjects&gt;True&lt;/IncludeCompositeObjects&gt;
      &lt;TargetDatabaseName&gt;Portal_Deploy_Dev&lt;/TargetDatabaseName&gt;
      &lt;DeployScriptFileName&gt;CCA_DB.sql&lt;/DeployScriptFileName&gt;
      &lt;TargetConnectionString&gt;Data Source=Machine\SQLEXPRESS;Integrated Security=True;User ID=username;Password=password;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False&lt;/TargetConnectionString&gt;
      &lt;ProfileVersionNumber&gt;1&lt;/ProfileVersionNumber&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Command line parameters used:</p>
  
  <pre><code> /t:Build;Publish
   /p:SqlPublishProfilePath=..\DB\Publishing\Portal_Deploy_Dev.publish.xml
  </code></pre>