title: Integrating ASP.NET Core Identity db with an already created database in a Razor Pages app
body: <p>I have been following <a href="https://zoboko.com/read/aspnet-core-in-action-3d5l410j?hash=cb109d6fed876fa47bb992993b661e58" rel="nofollow noreferrer">this</a> book on how to Add Identity to an existing project (specifically section 14.4). I have done the following</p>
  <ul>
  <li>Added the ASP.NET Core Identity NuGet packages</li>
  <li>Configured Startup to use Authentication Middleware and added Identity services to the DI container</li>
  <li>Updated the EF Core data model with the Identity entities
  <br>
  <br></li>
  </ul>
  <blockquote>
  <p>Code for updating the EF Core data model to support Identity</p>
  </blockquote>
  <pre><code>namespace Hoook.Data
  
      {
          public class HoookDbContext : IdentityDbContext&lt;ApplicationUser&gt;
          {
              public HoookDbContext(DbContextOptions&lt;HoookDbContext&gt; options) : base(options)
              {
      
              }
              public DbSet&lt;Venture&gt; Ventures { get; set; }
          }
      }
  </code></pre>
  <blockquote>
  <p>Code for custom user type which inherits from IdentityUser</p>
  </blockquote>
  <pre><code>namespace Hoook.Data
  
  {
      public class ApplicationUser : IdentityUser
      {
  
      }
  }
  </code></pre>
  <blockquote>
  <p>Startup.cs code for adding Identity service to DI</p>
  </blockquote>
  <pre><code>services.AddDefaultIdentity&lt;ApplicationUser&gt;(options =&gt;
                  options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores&lt;HoookDbContext&gt;();
  </code></pre>
  <p>Now I have then ran the following command in VSCode
  <code>dotnet ef migrations add AddIdentitySchema</code>
  <br>
  Then I ran <code>dotnet ef database update</code>
  <br>
  At this point I am to assume my database is updated and contains the Identity tables, but that is incorrect. How Am I to add the Identity tables to my existing database? I have searched through these <a href="https://stackoverflow.com/questions/25651342/how-to-add-asp-net-mvc5-identity-authentication-to-existing-database/25651908#25651908">1</a>, <a href="https://stackoverflow.com/questions/20668328/using-asp-net-identity-database-first-approach">2</a>, <a href="https://stackoverflow.com/questions/28636511/how-to-create-asp-net-identity-tables-inside-existing-database?noredirect=1&amp;lq=1">3</a> stackoverflow questions with no luck.
  <br>
  Adding a screenshot of my SSMS Migration History and tables. The migration took but no Identity tables have been populated.
  <br>
  <br>
  <a href="https://i.stack.imgur.com/SHBxv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SHBxv.png" alt="enter image description here" /></a></p>
  <p><br>
  <strong>UPDATE</strong>
  <br>
  It may help to note, I have created an Identity app using the .NET Core CLI with <code>new webapp -au Indi-  vidual -uld</code>. Inside the migrations of that app after running <code>dotnet ef database update</code>, the Migrations up and down methods are actually populated. However in my app when adding the migration following the above steps, my Migration file looks as so:</p>
  <pre><code>using Microsoft.EntityFrameworkCore.Migrations;
  
  #nullable disable
  
  namespace Hoook.Migrations
  {
      public partial class AddIdentitySchema : Migration
      {
          protected override void Up(MigrationBuilder migrationBuilder)
          {
  
          }
  
          protected override void Down(MigrationBuilder migrationBuilder)
          {
  
          }
      }
  }
  </code></pre>