Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp成员角色问题_C#_Asp.net_Sql - Fatal编程技术网

C# asp成员角色问题

C# asp成员角色问题,c#,asp.net,sql,C#,Asp.net,Sql,我在尝试使用默认成员资格提供程序向角色添加用户时遇到问题。 我在数据库中安装了asp.net模式,正在创建用户,这些用户工作正常,并在dbo.users中创建用户 Membership.CreateUserUserUserName.Text、Password.Text、Email.Text、null、null、true、out-createStatus 但是,当我尝试将用户添加到角色时 Roles.AddUserToRole(newUser.UserName, "administrators")

我在尝试使用默认成员资格提供程序向角色添加用户时遇到问题。 我在数据库中安装了asp.net模式,正在创建用户,这些用户工作正常,并在dbo.users中创建用户

Membership.CreateUserUserUserName.Text、Password.Text、Email.Text、null、null、true、out-createStatus

但是,当我尝试将用户添加到角色时

Roles.AddUserToRole(newUser.UserName, "administrators");
它保持返回异常,内部异常为

{"Invalid column name 'RoleId'.\r\nInvalid column name 'UserId'.\r\nInvalid column name 'UserId'.\r\nInvalid column name 'RoleId'."}
不确定当数据库中存在所有成员资格表时,为什么会声称列不存在

这让我在过去的几个小时里挠头


任何有帮助的想法都将不胜感激

您确定您也在使用默认角色提供程序吗?是的,我相信是这样,在web.config中,它似乎试图引用dbo.aspnet_UsersInRoles中的列,而不是dbo.UsersInRoles中的列。不确定为什么正确的表名以aspnet\uUmm开头。。。数据库中的所有成员资格表不是都以该名称开头吗?aspnet_uu是sqlmembership提供程序的前缀,现在已过时。使用默认membership提供程序时,应使用不带前缀的表