this code for create a role in database .
IdentityConfig:
public class ApplicationRoleManager : RoleManager<IdentityRole>
{
public ApplicationRoleManager(RoleStore<IdentityRole> roleStore)
: base(roleStore)
{
}
public static ApplicationRoleManager Create(IOwinContext context)
{
var roleStore = new RoleStore<IdentityRole>(context.Get<ApplicationDbContext>());
return new ApplicationRoleManager(roleStore);
}
}
but in Startup.Auth show me error :
How can I solve this error ?
Edit
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
Signature for CreatePerOwingContext<T>
looks like this:
public static IAppBuilder CreatePerOwinContext<T>(this IAppBuilder app, Func<IdentityFactoryOptions<T>, IOwinContext, T> createCallback) where T : class, IDisposable
or like this:
public static IAppBuilder CreatePerOwinContext<T>(this IAppBuilder app, Func<T> createCallback) where T : class, IDisposable
I.e. you ether need to provide a function that will create you an object, i.e.
app.CreatePerOwinContext<ApplicationRoleManager>(() => new ApplicationRoleManager(/*blah params*/));
This will be using second override. Or go back to defaults:
public static ApplicationRoleManager Create(IdentityFactoryOptions<ApplicationRoleManager> options, IOwinContext context)
{
var applicationDbContext = context.Get<ApplicationDbContext>();
var roleStore = new RoleStore<IdentityRole>(applicationDbContext);
var manager = new ApplicationRoleManager(roleStore);
return manager;
}