Search code examples
asp.netasp.net-mvcasp.net-mvc-5asp.net-identitysimplemembership

User.IsInRole failing after migrating to Identity 2.0


I have recently updated my MVC 4 application to MVC 5 and Identity 2.0 however I'm having difficulty to get it working. After logging in I get the error "No user found was found that has the name" and entity framework is still creating the old simplemembership tables "webpages_Membership", "webpages_OAuthMembership", "webpages_Roles", and "webpages_UsersInRoles".

I have used the Identity 2.0 methods for adding a new user and role for an admin account and these are showing up in those tables.

So my question is how to I remove any remaining links to simplemembership so that I am only using Identity 2.0. I don't even know where to look to find things to remove.

for reference I am working on visual studio 2012 with the MVC 5 update and tools installed. I have no need to keep existing users so no need to worry about migrating data. Just need help figuring out why it's still using simplememebership


Solution

  • If your app uses the User.IsInRole() method, add the following to the Web.config file.

    <system.webServer>
        <modules>
          <remove name="RoleManager" />
        </modules>
      </system.webServer>
    

    I came across the same issue, I found the details here (4. At the bottom of the page):

    How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2