title: Entity Framework Core migrations error using UseInMemoryDatabase
body: <p>I'm trying to separate my Entity Framework and Identity to a different library but I can't do any migrations when I use <code>builder.UseInMemoryDatabase(connectionString);</code>.</p>
  
  <p>I can do migrations when I change it to <code>builder.UseSqlServer(connectionString);</code>, but I need to use <code>UseInMemoryDatabase</code>.</p>
  
  <p>Here is the error when I try to add migration:</p>
  
  <blockquote>
    <p>Unable to resolve service for type Microsoft.EntityFrameworkCore.Migrations.IMigrator'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.`</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>using Microsoft.AspNetCore.Identity;
  using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
  using Microsoft.EntityFrameworkCore;
  using Microsoft.EntityFrameworkCore.Design;
  using Microsoft.EntityFrameworkCore.InMemory;
  using Microsoft.Extensions.Configuration;
  using System;
  using System.IO;
  
  namespace ClassLibrary1
  {
      public class ApplicationUser : IdentityUser
      {
      }
  
      public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
          public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
              : base(options)
          {
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              //modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
              base.OnModelCreating(modelBuilder);
          }
      }
  
      public class ApplicationDbContextFactory : IDesignTimeDbContextFactory&lt;ApplicationDbContext&gt;
      {
          public ApplicationDbContextFactory()
          {
          }
  
          public ApplicationDbContext CreateDbContext(string[] args)
          {
              IConfigurationRoot configuration = new ConfigurationBuilder()
                  .SetBasePath(Directory.GetCurrentDirectory())
                  .AddJsonFile("appsettings.json")
                  .Build();
  
              var builder = new DbContextOptionsBuilder&lt;ApplicationDbContext&gt;();
              var connectionString = configuration.GetConnectionString("DefaultConnection");
              builder.UseInMemoryDatabase(connectionString);
  
              return new ApplicationDbContext(builder.Options);
          }
      }
  }
  </code></pre>
  
  <p>and this is the reference</p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.2.1" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>but the <code>using Microsoft.EntityFrameworkCore.InMemory;</code> is unused namespace.</p>