title: ASP.NET: Check if run from migration
body: <p>I have some code in my <code>ConfigureServices</code> that fails when running a migration:</p>
  
  <pre><code>dotnet ef migrations list
  </code></pre>
  
  <p>I'm trying to add a Certificate but it can't find the file (it works when starting the project as a whole). So is there a way to do something like this:</p>
  
  <pre><code>if (!CurrentEnvironment.IsMigration()) {
      doMyStuffThatFailsInMigration()
  }
  </code></pre>
  
  <p>That way I could keep my code as it is but just execute it when not running it in a migration.</p>
  
  <p>Thanks</p>