So, I have been searching all over the internet for a solution. I've done a lot of research and it has only left me more lost. I am creating an MVC 5 site for Azure and I am having trouble setting up Role Management.
When I use the Roles object I get an error of "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'" I found this link but I don't know how it would apply to Azure.
My web.config file is currently set up like this.
<add name="RoleDB" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Techdb3.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<roleManager enabled="true">
<providers>
<clear/>
<add connectionStringName="RoleDB"
name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
applicationName="TechAndGames" />
</providers>
</roleManager>
For MVC 5, you need to remove the roleManager
tag, I think. I was using <roleManager>
in my latest MVC 5 application and was getting the exact same error as you. As soon as I removed it, the error went away. I think this is because MVC uses a different role management approach.
A couple of other things: make sure you have the proper tables setup in your database. These are the tables you will need:
You may not need all of these, depending on what you are doing. To get these setup properly, I (1) created a new project with the MVC 5 template, (2) ran the project locally (3) went through the registration process of a new user on the site and (4) looked in my local SQL server (LocalDb)\v11.0 and it had created a database there with all the tables I mention above. I then scripted those tables out and ran the scripts against my real database.
Then, in your application you should be able to call User
and get access to methods like User.IsInRole("someRole");
.