Creating Roles in Asp.net Identity MVC 5

前端 未结 11 1404
情深已故
情深已故 2020-12-02 05:09

There is very little documentation about using the new Asp.net Identity Security Framework.

I have pieced together what I could to try and create a new Role and add

11条回答
  •  被撕碎了的回忆
    2020-12-02 05:53

    My application was hanging on startup when I used Peter Stulinski & Dave Gordon's code samples with EF 6.0. I changed:

    var roleManager = new RoleManager(new RoleStore(new ApplicationDbContext()));
    

    to

    var roleManager = new RoleManager(new RoleStore(**context**));
    

    Which makes sense when in the seed method you don't want instantiate another instance of the ApplicationDBContext. This might have been compounded by the fact that I had Database.SetInitializer(new ApplicationDbInitializer()); in the constructor of ApplicationDbContext

提交回复
热议问题