title: EF Core - Table '*.__EFMigrationsHistory' doesn't exist
body: <p><em>I want to stress out that this is .NET Core and the threads about EF 6.0 does not apply to this problem</em></p>
  
  <p>I created my DbContext and added it in DI, however when I do <code>dotnet ef database update -v</code> it does not want to create the migrations table <code>__EFMigrationsHistory</code>.</p>
  
  <p>Is there some other command that I should do first or this is a bug of EF Core MySQL adapter?</p>
  
  <h3>MainDbContext</h3>
  
  <pre><code>using Microsoft.EntityFrameworkCore;
  using MySQL.Data.EntityFrameworkCore.Extensions;
  using Web.Models;
  
  namespace Web.Infrastructure
  {
      public class MainDbContext : DbContext
      {
          public DbSet&lt;User&gt; Users { get; set; }
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              optionsBuilder.UseMySQL("connection-string-here");
              base.OnConfiguring(optionsBuilder);
          }
      }
  }
  </code></pre>
  
  <h3>Error</h3>
  
  <blockquote>
    <p>Finding DbContext classes...</p>
    
    <p>Using context 'MainDbContext'.</p>
    
    <p>Using database 'db' on server 'localhost'.</p>
    
    <p>MySql.Data.MySqlClient.MySqlException: Table 'db.__EFMigrationsHistory' doesn't exist</p>
    
    <p>Table 'db.__EFMigrationsHistory' doesn't exist
    ```</p>
  </blockquote>
  
  <h3>project.json</h3>
  
  <pre><code>{
    "dependencies": {
      "Microsoft.NETCore.App": {
        "version": "1.0.1",
        "type": "platform"
      },
      "Microsoft.AspNetCore.Diagnostics": "1.0.0",
      "Microsoft.AspNetCore.Mvc": "1.0.1",
      "Microsoft.AspNetCore.Razor.Tools": {
        "version": "1.0.0-preview2-final",
        "type": "build"
      },
      "Microsoft.AspNetCore.Routing": "1.0.1",
      "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
      "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
      "Microsoft.AspNetCore.StaticFiles": "1.0.0",
      "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
      "Microsoft.Extensions.Configuration.Json": "1.0.0",
      "Microsoft.Extensions.Logging": "1.0.0",
      "Microsoft.Extensions.Logging.Console": "1.0.0",
      "Microsoft.Extensions.Logging.Debug": "1.0.0",
      "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
      "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
      "BundlerMinifier.Core": "2.2.301",
      "WebMarkupMin.AspNetCore1": "2.2.1",
      "MySql.Data.EntityFrameworkCore": "7.0.6-IR31",
      "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final"
    },
    "tools": {
      "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
      "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
      "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
    },
    "frameworks": {
      "netcoreapp1.0": {
        "imports": [
          "dotnet5.6",
          "portable-net45+win8"
        ]
      }
    },
    "buildOptions": {
      "emitEntryPoint": true,
      "preserveCompilationContext": true
    },
    "runtimeOptions": {
      "configProperties": {
        "System.GC.Server": true
      }
    },
    "publishOptions": {
      "include": [
        "wwwroot",
        "**/*.cshtml",
        "appsettings.json",
        "web.config"
      ]
    },
    "scripts": {
      "prepublish": [ "bower install", "dotnet bundle" ],
      "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
    }
  }
  </code></pre>
  
  <h3>Temp Solution</h3>
  
  <p>By executing <code>dotnet ef migrations script</code> I get SQL code that I can execute directly in MySQL. After that migrations table is created and everything works normally. This is temp-solution which is bad. I still wonder what is the "correct" way of enabling migrations.</p>