question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when creating roles

See original GitHub issue

Hi,

I’ve been tinkering with your app, converting it for use in a prerendering / universal app, and it’s taught me a lot thank you! For the most part I had no issues other than you’d expect with things like ngx-datatable which I had to replace with normal bootstrap styled tables.

There is a problem that I cant solve though, I thought it may just be me, so I downloaded a fresh copy of the master and tested, turns out it’s a bug.

To reproduce, login as admin > go to settings > Role Managment > new Role > Complete form (I used all permissions).

The error is :

error Cannot create an instance of abstract type System.Collections.Generic.ICollection1[Microsoft.AspNetCore.Identity.IdentityUserRole1[System.String]]. Parameter name: type

No doubt because of having to add the navigation properties for .net core 2.0, which had me running in circles until I saw you’d got it working.

I added break points and it seems to be when the Mapper is fired in the account controller>CreateRole method:

ApplicationRole appRole = Mapper.Map<ApplicationRole>(role);

I’m not really sure how to fix it, I did think of mapping it manually, so it would behave more like the DbInitializer role creation, but that option seems to be quite messy.

Again thank you for the time you took to make this, hopefully one day I can implement the things I’ve learned tinkering and actually make some money 🥇

EDIT: I went ahead and done it manually whilst waiting to see if a fix is forthcoming. I replaced the mapper with:

        ApplicationRole appRole = new ApplicationRole()
        {
          Name = role.Name,
          Description = role.Description
        };

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
asecginlicommented, Nov 5, 2017

Is 's worked correctly

2reactions
wrenhansencommented, Oct 5, 2017

@CybrZr00 Shoot I was not correct. I had been trying so many different things to try to correct the error and when it started working I figured the change I had made to the ApplicationDbContext must have been the fix. I reverted back to an original copy and modified this: public virtual ICollection<IdentityUserRole<string>> Users { get; set; } public virtual ICollection<IdentityRoleClaim<string>> Claims { get; set; } To be this:

public virtual List<IdentityUserRole<string>> Users { get; set; } public virtual List<IdentityRoleClaim<string>> Claims { get; set; }

Sorry for the incorrect piece but this is working well for me now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Create Role Error
I'm trying to Create Role using GP tool and encounter error. [Operation succeeded with warning messages written to error log file] Error ...
Read more >
error trying to create a Role · Issue #224 · kubernetes/kubectl
i tried to create the Role with a cluster running in aws using the file below kind: Role apiVersion: rbac.authorization.k8s.io/v1beta1 ...
Read more >
Troubleshoot IAM assume role errors "AccessDenied" or " ...
I tried to assume a cross-account AWS Identity and Access Management (IAM) role. · "An error occurred (AccessDenied) when calling the AssumeRole ...
Read more >
c# - I'm getting an error when create role in asp.net identity ...
When I try to create new role in identity I get this error. Value cannot be null.\r\n Parameter name: manager. This my controller...
Read more >
404 error when creating a new role
When creating a new role I am receiving a 404 error: Page not found. when saving the changes. Is there a way around...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found