I'm trying to learn how to use Sql Role Provider in a test mvc application. I have configured the web.config file and am connecting to a pre-existing sql server database (meaning I am not the one that created it).
protected void Application_Start()
{
if (Roles.RoleExists("Admin") == false)
{
Roles.CreateRole("Admin");
Roles.AddUserToRole("DOMAIN\\username", "Admin");
}
}
This code fails on Roles.CreateRole with Cannot insert the value NULL into column 'RoleId'
. From what I have read, this value should be auto-generated. Is this the case? Do I need to change RoleId to Is Identity, Yes?