aspnetcorehero / Boilerplate

Clean Architecture Solution Template for ASP.NET Core 5.0. Built with Onion/Hexagonal Architecture and incorporates the most essential Packages your projects will ever need. Includes both WebApi and Web(MVC) Projects.
https://codewithmukesh.com/project/aspnet-core-hero-boilerplate/
MIT License
582 stars 148 forks source link

Connection Already Exist #25

Closed webzest closed 3 years ago

webzest commented 3 years ago

Describe the bug InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.

To Reproduce Steps to reproduce the behavior: Generated a new application with dotnet. Upgraded to the latest Nuget packages. Conducted the Migrations to create the new database on my local MSSQL 2019 Server Tested the Token API Successfully. Selected the Web as default App and logged in with the default Super Admin User

  1. Go to 'Admin Settings'
  2. Click on 'Users'
  3. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Desktop (please complete the following information):

Additional context Clicking on Roles worked, but the remaining links did not. Same error was generated

scrnjakovic commented 3 years ago

I reported same issue in #21 two weeks ago although in my case MS SQL worked, while MySQL and postgresql didn't. Same error, same thing regarding only Roles section working. If you find something out, let me know, as it doesn't look like we'll be getting help here :)

iamshen commented 3 years ago

in postgres

Your.Web/Permission/PermissionAuthorizationHandler.cs

var userRoles = _roleManager.Roles.Where(x => userRoleNames.Contains(x.Name));

change to

var userRoles = _roleManager.Roles.Where(x => userRoleNames.Contains(x.Name)).ToList();

This is because do foreach over an EF Core LINQ query isn't supported

webzest commented 3 years ago

Yes, that is the solution. Thank You!

thanhdongha commented 2 years ago

thanks, it's worked for me