在数据库中找不到 ASP.NET 个身份表

Cannot Find ASP.NET Identity Tables in Database

我使用 EF 代码优先迁移方法创建了一个数据库。当我 运行 应用程序时,我注册了一个用户,并希望将身份表添加到我创建的数据库中,但我找不到这些表。我检查了我的连接字符串以确保它设置正确。请问我错过了什么?请帮忙

编辑: 这是上下文的代码。

public class AppDataContext : DbContext
{
    public AppDataContext()
        : base("AppConnection")
    { }

    public DbSet<AppUser> AppUsers { get; set; }

    public DbSet<Attendance> Attendances { get; set; }

    public DbSet<ClassInfo> Classes { get; set; }

    public DbSet<Enrollment> Enrollments { get; set; }

    public DbSet<MessageBoard> MessageBoards { get; set; }

    public DbSet<Notification> Notifications { get; set; }

    public DbSet<Notification_User> UserNotifications { get; set; }

    public DbSet<NotificationType> NotificationTypes { get; set; }

    public DbSet<Parent> Parents { get; set; }

    public DbSet<ParentSubscription> ParentSubscriptions { get; set; }

    public DbSet<PrivateMessage> PrivateMessages { get; set; }

    public DbSet<School> Schools { get; set; }

    public DbSet<SessionPeriod> SessionPeriods { get; set; }

    public DbSet<Setting> Settings { get; set; }

    public DbSet<Student> Students { get; set; }

    public DbSet<Subject> Subjects { get; set; }

    public DbSet<Teacher> Teachers { get; set; }

    public DbSet<TeacherSchool> TeacherSchools { get; set; }

    public DbSet<Term> Terms { get; set; }

    public DbSet<Work> Works { get; set; }

    public DbSet<WorkType> WorkTypes { get; set; }

    #region Override Methods

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

        modelBuilder.Entity<Subject>()
        .HasMany(c => c.Teachers).WithMany(i => i.Subjects)
        .Map(t => t.MapLeftKey("SubjectID")
        .MapRightKey("TeacherID")
        .ToTable("SubjectTeacher"));

        modelBuilder.Entity<ClassInfo>()
            .HasMany(s => s.Subjects).WithMany(c => c.Classes)
            .Map(u => u.MapLeftKey("ClassInfoID").MapRightKey("SubjectID").ToTable("ClassSubject"));

        //modelBuilder.Entity<Department>().MapToStoredProcedures();

        modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

        //modelBuilder.Entity<ClassInfo>()
        //    .Property(f => f.DateAdded)
        //    .HasColumnType("datetime2");
    }

    #endregion
}

当您注册用户时:

  1. 刷新你的项目
  2. 显示所有文件

您会发现:

编辑:

IdentityModels.cs:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        //: base("DefaultConnection", throwIfV1Schema: false)
        : base("AppConnection", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}

public class AppDataContext : DbContext
{
    public AppDataContext()
        : base("AppConnection")
    { }


}

Web.config:

 <connectionStrings>
      <add name="AppConnection" connectionString="Data Source=.; Initial Catalog=SIS_DB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
  </connectionStrings>