Hi @kobosh ,
Do you mean the Lesson and Instructor table is not created in the database? If that is the case, you could refer the following steps:
- Create a Asp.net core 5 with authentication (user individual account)
- Create Lesson class and Instructor class:
public class Instructor { public int Id { get; set; } public string Name { get; set; } } public class Lesson { public int Id { get; set; } public string LessonName { get; set; } }
- Modify the ApplicationDbContext as below:
}public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } public DbSet<Lesson> Lesson { get; set; } public DbSet<Instructor> Instructor { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<Lesson>().ToTable("Lesson"); modelBuilder.Entity<Instructor>().ToTable("Instructor"); }
- In the Package Manager Console, run the follow migration command:
add-migration addlesson
update-database
- After running the above command success, the table has already created in the database:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion