I created a database using using EF Code-first Migrations approach. When I ran the application I registered a user and expected that the identity tables be added to the database I created but I couldn't find the tables. I checked my connection string to be sure it is rightly set. Please what could I have missed out? Please help.
Edit: This is the code for the context.
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
}
When you registered a user :
You will find:
Edit:
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>