title: How to use SMO ServerConnection and Database with a contained user in Azure SQL Database
body: <p>Is there way to use SMO for user who have no access to <code>master</code>?</p>
  
  <p>I am scripting out the DLL of an Azure SQL Database via SMO. I used a contained user with db_owner role to access the db and DDL but it throws exception. SMO as soon as I create ServerConnection attempts to default to <code>master</code> from which this contained user have no permission.</p>
  
  <p>I used the latest SMO version released on nuget and code in .NET Core 3.0. </p>
  
  <pre class="lang-sql prettyprint-override"><code>--exec in master db
  CREATE LOGIN testuser WITH PASSWORD='...';
  
  --exec in user db: testsqldb
  CREATE USER testuser FROM LOGIN testuser
  ALTER ROLE db_owner ADD MEMBER testuser
  </code></pre>
  
  <p>The connection string has <code>InitialCatalog = testsqldb</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>var connectionStringBuilder = new SqlConnectionStringBuilder(sourceConnectionString);
  var serverConnection = CreateServerConnection(_connectionString);
  
  //this throws exception
  var server = new Server(serverConnection);
  </code></pre>
  
  <p>Exception details</p>
  
  <pre class="lang-cs prettyprint-override"><code>{"The server principal \"testuser\" is not able to access the database \"master\" under the current security context.\r\nCannot open user default database. Login failed.\r\nLogin failed for user 'testuser'."}
  </code></pre>
  
  <p>I expect the ServerConnection to respect the InitialCatalog specified in the ConnectionString and not default to 'master'</p>