Error Message : The entity type IdentityRole is not part of the model for the current context
the above Error show when access to this code
Code
if (!roleManager.RoleExists("MasterAdmin"))- public void CreateDefaultRolesAndUsers()
- {
- var roleManager = new RoleManager
( new RoleStore(db)); - var userManager = new UserManager
( new UserStore(db)); - IdentityRole role = new IdentityRole();
- if (!roleManager.RoleExists("MasterAdmin"))
- {
- role.Name = "MasterAdmin";
- roleManager.Create(role);
- ApplicationUser user = new ApplicationUser();
- user.UserName = "enmaMasterAdmin";
- user.Email = "[email protected]";
- var check = userManager.Create(user,"Master/77777777");
- if (check.Succeeded)
- {
- userManager.AddToRole(user.Id, "MasterAdmin");
- }
- }
- }
Note \ I use Database First Approach


Answers
Know the answer? Post it. Somebody with the same question will find it here.