title: .NET Core with MySQL
body: <p>I have seen some videos of people using other database systems with .NET Core, and wanted to use MySQL with an app I am building. I am getting an exception when I run my app after adding this line to my ConfigureServices method.</p>
  
  <pre><code>services.AddEntityFrameworkMySql().AddDbContext&lt;MyDbContext&gt;(ServiceLifetime.Singleton);
  </code></pre>
  
  <p>My project.json file is mostly unchanged except for adding these packages.</p>
  
  <pre><code>"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",  
  "Pomelo.EntityFrameworkCore.MySql": "1.1.0",
  "Microsoft.EntityFrameworkCore.Relational": "1.1.0"
  </code></pre>
  
  <p>Here is my final project.json file.</p>
  
  <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",
      "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",  
      "Pomelo.EntityFrameworkCore.MySql": "1.1.0",
      "Microsoft.EntityFrameworkCore.Relational": "1.1.0"
    },
  
    "tools": {
      "BundlerMinifier.Core": "2.0.238",
      "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
      "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
      "Microsoft.AspNetCore.Server.IISIntegration.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>
  
  <p>What do I need in order for it to work correctly? In MyDbContext, I've overridden the OnConfiguring method to use my connection string.</p>
  
  <pre><code> protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  
      =&gt; optionsBuilder.UseMySql(@"Server=localhost;database=MyTestDb;uid=root;pwd=pwd;");  
  </code></pre>
  
  <p>Where have I gone wrong? I get this exception as mentioned, in Startup.cs in the configure services method,</p>
  
  <blockquote>
    <p>An exception of type 'System.IO.FileLoadException' occurred in
    Microsoft.EntityFrameworkCore.Relational.dll but was not handled in
    user code</p>
    
    <p>Additional information: Could not load file or assembly
    'Microsoft.Extensions.Logging.Abstractions, Version=1.1.0.0,
    Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located
    assembly's manifest definition does not match the assembly reference.
    (Exception from HRESULT: 0x80131040)</p>
  </blockquote>