asp.net-mvc – System.Data.SqlClient.SqlException:无效的对象名称’dbo.Projects’

我的MVC应用程序在尝试访问数据库中的任何表时返回sqlExceptions.

异常详细信息:System.Data.sqlClient.sqlException:无效的对象名称“dbo.Projects”.

我的应用程序我们linq为数据层.

如果我使用旧的dll它工作正常(所以似乎不是一个问题的DB)只是这个最新的应用程序DLL,我已经上传.

细节

[sqlException (0x80131904): Invalid object name ‘dbo.Projects’.]
System.Data.sqlClient.sqlConnection.OnError(sqlException exception,
Boolean breakConnection) +1950890
System.Data.sqlClient.sqlInternalConnection.OnError(sqlException
exception,Boolean breakConnection) +4846875
System.Data.sqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +194 System.Data.sqlClient.TdsParser.Run(RunBehavior
runBehavior,sqlCommand cmdHandler,sqlDataReader dataStream,
BulkcopySimpleResultSet bulkcopyHandler,TdsParserStateObject
stateObj) +2392
System.Data.sqlClient.sqlDataReader.ConsumeMetaData() +33
System.Data.sqlClient.sqlDataReader.get_MetaData() +83
System.Data.sqlClient.sqlCommand.FinishExecuteReader(sqlDataReader ds,
RunBehavior runBehavior,String resetoptionsstring) +297
System.Data.sqlClient.sqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean
async) +954
System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior,String
method,DbAsyncResult result) +162
System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior,String
method) +32
System.Data.sqlClient.sqlCommand.ExecuteReader(CommandBehavior
behavior,String method) +141
System.Data.sqlClient.sqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +12 System.Data.Common.DbCommand.ExecuteReader() +12
System.Data.Linq.sqlClient.sqlProvider.Execute(Expression query,
QueryInfo queryInfo,IObjectReaderFactory factory,Object[]
parentArgs,Object[] userArgs,ICompiledSubQuery[] subQueries,Object
lastResult) +975
System.Data.Linq.sqlClient.sqlProvider.Executeall(Expression query,
QueryInfo[] queryInfos,Object[]
userArguments,ICompiledSubQuery[] subQueries) +113
System.Data.Linq.sqlClient.sqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression
query) +344
System.Data.Linq.DataQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
+35 System.Linq.Buffer
1..ctor(IEnumerable1 source) +247 System.Linq.<GetEnumerator>d__0.MoveNext() +108
System.Linq.Buffer
1..ctor(IEnumerable1 source) +259
System.Linq.<GetEnumerator>d__0.MoveNext() +108
System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
+7665172 System.Linq.Enumerable.ToList(IEnumerable
1 source) +61 Mezza_crm.Controllers.ProjectsController.GetProjectList(NameValueCollection form) in C:\mezza_crm\mezza_crm\Controllers\ProjectsController.cs:164
Mezza_crm.Controllers.ProjectsController.List() in
C:\mezza_crm\mezza_crm\Controllers\ProjectsController.cs:53
lambda_method(ExecutionScope,ControllerBase,Object[] ) +39
System.Web.Mvc.ActionMethoddispatcher.Execute(ControllerBase
controller,Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext,IDictionary2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext,ActionDescriptor actionDescriptor,IDictionary
2
parameters) +24
System.Web.Mvc.<>c__displayClassa.b__7()
+52 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter,ActionExecutingContext preContext,Func1 continuation) +254
System.Web.Mvc.<>c__displayClassc.<InvokeActionMethodWithFilters>b__9()
+19 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
controllerContext,IList
1 filters,
IDictionary`2 parameters) +192
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext,String actionName) +399
System.Web.Mvc.Controller.ExecuteCore() +126
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
+27 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
+151 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext
httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +75

解决方法

检查连接字符串中的初始目录参数.可能是您的代码正在为Projects对象查找错误数据库.

例如,如果您具有数据库同步设置,只有主数据库表的一部分被传输,那么如果Linq to sql希望所有表都位于连接字符串指向的数据库中,则可能会遇到此错误.

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...