title: Entity Framework Core apply migrations programmatically
body: <p>I have test and live db. For test db migrations I use <code>Add-Migration ...</code> and <code>Update-Database</code> syntax in package manager console. But for live db I want to do it programmatically when app is started. </p>
  
  <p>The following code didn't help me:</p>
  
  <pre><code>context.Database.Migrate();
  </code></pre>
  
  <p>I have error <code>Invalid object name 'TempTenants'</code> when I try to add record to table that doesn't exist. This is my new table.</p>
  
  <p>But I have <code>_EFMigrationsHistory</code> table. And there are all my migrations even those that weren't applied. But I don't see new table.</p>
  
  <p>I will have the same result if I manually remove table from test db and try to reproduce error.</p>
  
  <p>So, <code>context.Database.Migrate();</code> only create new db with all migrations, if it doesn't exist, but don't update (apply migrations) existing db.</p>
  
  <p>Can I do that? And how can I resolve that?</p>