here is my ApplicationUser and dbContext Class
public class ApplicationUser : IdentityUser { public int? studentID { get; set; } [ForeignKey("studentID")] public virtual Student Student { get; set; } } public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("DefaultConnection") { } public DbSet<ApplicationRole> ApplicationRoles { get; set; } public static ApplicationDbContext Create() { return new ApplicationDbContext(); } } and my Application Role class
public class ApplicationRole : IdentityRole { public ApplicationRole(string name) : base(name) { } public ApplicationRole() { } public string Description { get; set; } } in my roles controller
public class RolesController : Controller { private ApplicationDbContext db = new ApplicationDbContext(); // GET: /Roles/ public ActionResult Index() { return View(db.Roles.ToList()); } db.Roles.ToList() shows nothing. but i have put some roles in database. db.Roles.ToList() returns no list. shows "Enumeration yielded no results"
Please help me. I want to crate roles and i have to use roleID to another table as foreign key. What wrong with this. i need a simple solution. Thank you.