Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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.NET MVC 5无效的对象名称';dbo.UsersInRoles';_C#_Asp.net Mvc_Asp.net Mvc 5 - Fatal编程技术网

C# ASP.NET MVC 5无效的对象名称';dbo.UsersInRoles';

C# ASP.NET MVC 5无效的对象名称';dbo.UsersInRoles';,c#,asp.net-mvc,asp.net-mvc-5,C#,Asp.net Mvc,Asp.net Mvc 5,我正在做我的ASP.NETMVC5项目 这是我的管理代码 [Authorize(Roles = "Admin")] public ActionResult Admin() { return View(UserManager.Users); } 我所要做的就是能够从数据库中删除用户以及AspNetUserRoles中的相关记录 我将其添加到system.web部分中的web.config中 尝试打开/Admin页面时,会引发异常: 无效的对象名

我正在做我的ASP.NETMVC5项目

这是我的管理代码

    [Authorize(Roles = "Admin")]
    public ActionResult Admin()
    {
        return View(UserManager.Users);
    }
我所要做的就是能够从数据库中删除用户以及AspNetUserRoles中的相关记录

我将其添加到system.web部分中的web.config中


尝试打开/Admin页面时,会引发异常:

无效的对象名称“dbo.UsersInRoles”

描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

异常详细信息:System.Data.SqlClient.SqlException:无效对象 名称为“dbo.UsersInRoles”

源错误:

在执行过程中生成了未处理的异常 当前web请求。关于货物来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常

堆栈跟踪:

[SqlException(0x80131904):对象名“dbo.UsersInRoles”无效。]
System.Data.SqlClient.SqlConnection.OnError(SqlException异常, 布尔断开连接,操作
1 wrapCloseInAction)+1789294
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 异常,布尔断开连接,操作
1 wrapCloseInAction) +5340642 System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject stateObj,布尔调用方连接锁,布尔异步关闭)+244
System.Data.SqlClient.TdsParser.TryRun(运行行为, SqlCommand cmdHandler、SqlDataReader数据流、, BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj、布尔值和数据就绪)+1691
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()+61
System.Data.SqlClient.SqlDataReader.get_MetaData()+90
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, 运行行为运行行为,字符串重置选项字符串)+377
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior、RunBehavior、Boolean returnStream、Boolean 异步、Int32超时、任务和任务、布尔异步写入、SqlDataReader ds)+1421
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior、布尔返回流、字符串 方法,TaskCompletionSource
1完成,Int32超时,任务和任务,
布尔异步写入)+177
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior、布尔返回流、字符串 方法)+53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior 行为,字符串方法)+137
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior 行为)+41
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior) +10系统、数据、实体、基础设施、拦截、DbCommandDispatcher、b_u_c(DbCommand t、 DbCommandInterceptionContext
1c)+66
System.Data.Entity.Infrastructure.InternalDispatcher
1.Dispatch(TTarget
目标,函数
3操作,TInterceptionContext拦截context, 动作
3执行,动作
3执行)+138
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand 命令,dbcommandinterceptoncontext interceptoncontext)+475
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior 行为)+239
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior) +10 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand,CommandBehavior)+97

[EntityCommandExecutionException:执行时出错 命令定义。有关详细信息,请参阅内部异常。]
System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand 实体命令,命令行为)+181
System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext 上下文,ObjectParameterCollection parameterValues)+1282
System.Data.Entity.Core.Objects.c__DisplayClass7.b__6() +184 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func
1
func,IDbExecutionStrategy executionStrategy,布尔值
startLocalTransaction,布尔释放连接成功)+448
System.Data.Entity.Core.Objects.c__DisplayClass7.b__5() +270 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func
1 操作)+251
System.Data.Entity.Core.Objects.ObjectQuery
1.GetResults(可为null
1 forMergeOption)+645
System.Data.Entity.Core.Objects.ObjectQuery
1.b__0()
+68 System.Data.Entity.Internal.LazyEnumerator
1.MoveNext()+68 System.Linq.Buffer
1..ctor(IEnumerable
1 source)+216
System.Linq.Enumerable.ToArray(IEnumerable
1源代码)+77
System.Web.Providers.QueryHelper.GetRolesNamesForUser(MembershipContext ctx,字符串应用程序名,字符串用户名)+8129
System.Web.Providers.DefaultRoleProvider.GetRolesForUser(字符串 用户名)+219 System.Web.Security.RolePrincipal.IsInRole(字符串) 角色)+9612755系统。Linq.可枚举。任意(IEnumerable
1源代码, Func
2谓词)+146
System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext)+333
System.Web.Mvc.AuthorizationAttribute.OnAuthorization(AuthorizationContext 过滤器上下文)+379
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext,IList
1过滤器,ActionDescriptor ActionDescriptor) +143 System.Web.Mvc.Async.c\uuu DisplayClass21.b\uu 19(异步回调 异步回调,对象异步状态)+1680
System.Web.Mvc.A
<membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" 
         connectionstringname="DefaultConnection" enablepasswordretrieval="false" enablePasswordReset="true" 
    requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" 
    minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" 
    applicationName="/" />

  </providers>
</membership>
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
  <providers>
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider"
<system.webServer>
    <modules>
      <remove name="RoleManager" />
    </modules>
  </system.webServer>
<system.webServer>
  <modules>
    <remove name="FormsAuthenticationModule" />
  ...
<add name="DefaultConnection" 
     connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20140601125344.mdf;Initial Catalog=aspnet-WebApplication3-20140601125344;Integrated Security=True" />
[AllowAnonymous]
public class HomeController
{
  [Authorize]
  public ActionResult Index()
  {
    return View();
  }
}