title: Asp.net core - no such table: AspNetUsers
body: <p>So im trying to implment user login for my a asp.net core application. Im following the microsoft tutorial <a href="https://docs.asp.net/en/latest/security/authentication/identity.html" rel="noreferrer">here</a>. I have two contexts, one called SchoolContext for saving all the school related models, and another context called ApplicationDbContext for the Account models. This is all being saved to a sqlite database. <br>
  Everything works fine, up until I try to register a user to my context. When I try to register a user i get, cant find AspNetUsers table error. If I look in the database I don’t see the AspNetUser table. I tried adding <a href="https://docs.asp.net/en/latest/data/ef-mvc/migrations.html" rel="noreferrer">migrations</a>, but i still get that same error. Why is the table not being created ? </p>
  
  <p>Startup.cs</p>
  
  <pre><code>public class Startup {
          public IConfigurationRoot Configuration { get; }
          public Startup(IHostingEnvironment env) {
              var builder = new ConfigurationBuilder()
                  .SetBasePath(env.ContentRootPath)
                  .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                  .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                  .AddEnvironmentVariables();
              Configuration = builder.Build();
          }
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services) {
              // Add Context services
              services.AddDbContext&lt;SchoolContext&gt;(options =&gt;
                  options.UseSqlite(Configuration.GetConnectionString("MainConnection")));
              services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
                  options.UseSqlite(Configuration.GetConnectionString("MainConnection")));
  
              // Add Identify servies 
              services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
                  .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
                  .AddDefaultTokenProviders();
              // Add framework services
              services.AddMvc();
          }
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, SchoolContext context) {
              loggerFactory.AddConsole(Configuration.GetSection("Logging"));
              loggerFactory.AddDebug();
              // Config hot module replacement
              if (env.IsDevelopment()) {
                  app.UseDeveloperExceptionPage();
                  app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
                      HotModuleReplacement = true
                  });
              }
              else {
                  app.UseExceptionHandler("/Home/Error");
              }
              app.UseStaticFiles();
              // Enabled Identity
              app.UseIdentity();
              // Confgure routes 
              app.UseMvc(routes =&gt; {
                  routes.MapRoute(
                      name: "default",
                      template: "{controller=Home}/{action=Index}/{id?}");
  
                  routes.MapSpaFallbackRoute(
                      name: "spa-fallback",
                      defaults: new { controller = "Home", action = "Index" });
              });
              // Initialize school database [FOR TESTING] 
              DbInitializer.Initialize(context);
          }
      }
  </code></pre>
  
  <p>ApplicationDbContext.cs</p>
  
  <pre><code>namespace ContosoUniversity.Data
  {
      public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
          public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options): base(options)
          {
          }
  
          protected override void OnModelCreating(ModelBuilder builder)
          {
              base.OnModelCreating(builder);
          }
      }
  }
  </code></pre>
  
  <p>ApplicationUser.cs </p>
  
  <pre><code>namespace ContosoUniversity.Models
  {
      // Add profile data for application users by adding properties to the ApplicationUser class
      public class ApplicationUser : IdentityUser
      {
      }
  }
  </code></pre>
  
  <p>appsettings.json</p>
  
  <pre><code>  "ConnectionStrings": {
      "MainConnection": "Data Source=/home/Josn/AspNetCore/ContosoUniversity/Databases/database.db"
    },
  </code></pre>
  
  <p>Error </p>
  
  <pre><code>fail: Microsoft.EntityFrameworkCore.Query.RelationalQueryCompilationContextFactory[1]
        An exception occurred in the database while iterating the results of a query.
        Microsoft.Data.Sqlite.SqliteException: SQLite Error 1: 'no such table: AspNetUsers'.
           at Microsoft.Data.Sqlite.Interop.MarshalEx.ThrowExceptionForRC(Int32 rc, Sqlite3Handle db)
           at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
           at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
           at Microsoft.Data.Sqlite.SqliteCommand.&lt;ExecuteDbDataReaderAsync&gt;d__53.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.&lt;ExecuteAsync&gt;d__20.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.&lt;MoveNext&gt;d__8.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.&lt;_FirstOrDefault&gt;d__82`1.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at Microsoft.EntityFrameworkCore.Query.Internal.TaskResultAsyncEnumerable`1.Enumerator.&lt;MoveNext&gt;d__3.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.&lt;MoveNext&gt;d__5.MoveNext()
  </code></pre>