我有一个从另一个开发人员那里收到的MVC3应用程序。我已经设置了正确的数据库,并将其添加到我的Web.config中。有一个称为Location(s)的模型和控制器。
添加位置的控制器和视图是非常标准的CRUD,但是当我尝试添加位置时,Create方法抛出以下代码:
Invalid object name 'Locations_tracking'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Locations_tracking'.
Source Error:
Line 56: location.UpdatedAt = DateTime.Now;
Line 57: db.Locations.Add(location);
Line 58: db.SaveChanges();
Line 59: return RedirectToAction("Index");
Line 60: }我在我的整个应用程序中搜索了“跟踪”,但没有找到任何东西。为什么它要寻找这个"Locations_tracking“对象,为什么找不到呢?我假设它来自实体框架,因为我在控制器、模型或视图中看不到任何东西。谢谢你的帮助!
发布于 2012-01-18 07:13:55
在Locations表中查找触发器。考虑到这里缺少的表的名称,我认为它是一个由触发器提供的用于插入和更新的审计表。如果是这样的话,您可能有触发器,但没有表。
发布于 2012-01-18 04:10:54
这是一个SQL异常。看起来它正在尝试更新/插入到不存在的表Locations_tracking中。除了继承应用程序之外,您还继承了允许您创建此应用程序所依赖的数据库结构的SQL脚本吗?
https://stackoverflow.com/questions/8901030
复制相似问题