RoleManager, RoleStore sample code

Nov 26, 2014 at 3:56 PM
I am a novice in Asp.net Identity. Tried to find the sample code for using RoleManager and RoleStore to create roles in Azure Table storage. Did not find it in given sample app. Then tried to do it myself, but could not go ahead because of sorts of compile errors. Can anyone provide some sample code please?
Coordinator
Nov 28, 2014 at 4:03 AM
There are unit tests in the project that you can use as an example found here: https://identityazuretable.codeplex.com/SourceControl/latest#Main/identity/azuretable.tests/RoleStoreTests.cs
Marked as answer by dotnetdavy on 12/9/2014 at 7:37 PM
Dec 1, 2014 at 4:04 AM
Hello

That solved my issue. Thank you very much.

I thought that the initialization of RolesManager would be same as UserManager. Thought, passing dbContext to initialize RolesManager was necessary to make it save Roles to right place, i.e. like

var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));

From Test project, it was sort of clear that, initializing it without any parameters would suffice. And it will use the same context as of UserManager to save Roles.

None the less, you have helped my case a lot by making your module available on CodePlex.