title: SQL Server Express dev setup - access denied whack-a-mole
body: <p>I have a development environment in which I need to use IIS and SQL Server Express. My connection string looks like this:</p>
  
  <pre><code>&lt;add name="DefaultConnection" 
       connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyProject.mdf;Integrated Security=True;User Instance=True" 
       providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>This works great when I run the app and browse to the site. Data is returned from the database and I can log into Management Studio and view that data. The problem is when I try to push a new data migration using <code>Update-Database</code>. </p>
  
  <p>I then get this error message: </p>
  
  <blockquote>
    <p>Login failed for user 'AzureAD\MyAccount'</p>
  </blockquote>
  
  <p>If I remove <code>User Instance=True</code> from my connection string, the <code>Update-Database</code> command suddenly works! Then I refresh my page and see the following error from all endpoints that require the database:</p>
  
  <blockquote>
    <p>CREATE DATABASE permission denied in database 'master'.</p>
  </blockquote>
  
  <p>I have already tried the trick of deleting this folder. It did not solve it.</p>
  
  <pre><code>C:\Users\MyAccount\AppData\Local\Microsoft\Microsoft SQL Server Data
  </code></pre>
  
  <p>What gives?</p>