TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abdulmajeed Alshari
NA
266
60.7k
The entity type IdentityRole is not part of the model
Oct 5 2018 11:53 AM
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
if (!roleManager.RoleExists("MasterAdmin"))
my codes are placed in Startup File as the below :
public
void
CreateDefaultRolesAndUsers()
{
var roleManager =
new
RoleManager<IdentityRole>(
new
RoleStore<IdentityRole>(db));
var userManager =
new
UserManager<ApplicationUser>(
new
UserStore<ApplicationUser>(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
Reply
Answers (
0
)
how to get an item from a data source within a repeater
Asp.net MVC FileUpload