I\'m trying to use the new ASP.NET Identity in my MVC5 application, specifically I\'m trying to integrate ASP.NET Identity into an existing database. I\'ve already read the
You have to specify during the creation of User Store that AspNetRole is used instead of IdentityRole. You can achieve this by using the UserStore class with 6 type parameters:
new UserStore(new PayrollDBEntities());
This indicates changes at User Manager creation as well. Here is a simplified example about the creation of needed instances:
public class AspNetUser : IdentityUser { /*customization*/ }
public class AspNetRole : IdentityRole { /*customization*/ }
public class PayrollDBEntities : IdentityDbContext //or : IdentityDbContext
{
}
public class Factory
{
public IdentityDbContext DbContext
{
get
{
return new PayrollDBEntities();
}
}
public UserStore UserStore
{
get
{
return new UserStore(DbContext);
}
}
public UserManager UserManager
{
get
{
return new UserManager(UserStore);
}
}
public RoleStore RoleStore
{
get
{
return new RoleStore(DbContext);
}
}
public RoleManager RoleManager
{
get
{
return new RoleManager(RoleStore);
}
}
}