By following this tutorial Here I got to succesfully convert the User Id to int so i can use Linq with operations done on users in my application.
Everything worked fine here, but after creating default users in startup.cs like this:
public async Task CreateUsersAndRoles(IServiceScope serviceScope){
var userManager = serviceScope.ServiceProvider.GetService<UserManager>();
var roleManager = serviceScope.ServiceProvider.GetService<RoleManager>();
//Creating Admin role
await roleManager.CreateAsync(new IdentityRole("TopUser"));
var TopUsers = new ApplicationUser { UserName = "xxxxx@xx.com",
Email = "xxx@xxxx.com",
};
await userManager.CreateAsync(adminUser, "xxxxxx");
await userManager.AddToRoleAsync(TopUsers, "TopUser");
}
I am getting an error in CreateUsersAndRoles(serviceScope).Wait(); that is not clear and I don't know why the compiling is failing as eveything seems to be logically working.
Here is the error:
An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.' Inner exceptions found, see $exception in variables window for more details. Innermost exception System.NullReferenceException : Object reference not set to an instance of an object.
What am I doing wrong? And how do i find the error that is causing the code to fail?