locked
Initializing SqlRoleProvider in ASP MVC 5 RRS feed

  • Question

  • User79129305 posted

    I am attempting to set up the role provider for MVC 5 but I can not get any calls on the Roles object to work.  I receive the exception "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion". The RoleManager object and User.IsInRole calls work just fine but I  have no luck with the Roles object.

    Roles.GetRolesForUser(UserName)

    I have added these settings to the web.config

    <add name="SqlRoleManagerConnection" connectionString="Data Source=   (LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Techdb3.mdf;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    
    <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
      <providers>
        <add name="AspNetSqlRoleProvider"
             type="System.Web.Security.SqlRoleProvider"
             connectionStringName="SqlRoleManagerConnection"
             applicationName="MyApplication" />
      </providers>
    </roleManager>

    Friday, October 10, 2014 12:40 PM

Answers

  • User-734925760 posted

    Hi,

    According to your description and the code you provided, I think the roleManager has no error, so I think you need to make sure the connectionString is correct, then we can correct connect the DataBase. Then in the prociders, you need make sure the connectionStringName and applicationname are all correct.

    There is an artivle about RoleManager, please refer to the link below:

    http://msdn.microsoft.com/en-us/library/vstudio/ms164662(v=vs.100).aspx

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 13, 2014 4:31 AM

All replies

  • User79129305 posted

    PLEASE HELP: I am very close. I found that the <provider> tag breaks the provider. If I remove it the Roles object works but the role database is then created in a random database file. I'm guessing that the role tables and scripts are just not being created when I add it to my default connection.........I can't be the only one that has had this problem.

    Saturday, October 11, 2014 1:57 PM
  • User-734925760 posted

    Hi,

    According to your description and the code you provided, I think the roleManager has no error, so I think you need to make sure the connectionString is correct, then we can correct connect the DataBase. Then in the prociders, you need make sure the connectionStringName and applicationname are all correct.

    There is an artivle about RoleManager, please refer to the link below:

    http://msdn.microsoft.com/en-us/library/vstudio/ms164662(v=vs.100).aspx

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 13, 2014 4:31 AM