System.Data.EntityCommandExecutionException:执行th时发生错误

Dot*_*row 4 asp.net asp.net-mvc-3

我在mvc3应用程序中创建了一个连接字符串,它在mvc视图和控制器中工作正常,我能够获取数据.现在我在Test项目的单元测试中调用了存储库/模型函数,我收到错误:

System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid object name 'dbo.tblProduct'.
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

arc*_*hil 6

这与MVC无关.看起来,在测试时,您在没有'dbo.tblProduct'表/视图的数据库上使用ConnectionString.检查连接字符串和数据库.您可能需要调试测试