System.Data.EntityCommandExecutionException:执行日发生错误 [英] System.Data.EntityCommandExecutionException: An error occurred while executing th
问题描述
我已经创建了MVC3应用程序中的ConnectionString,它是MVC中的视图和控制器的工作很好,我能够获取数据。现在,我已经叫测试项目的单元测试库/模型功能,我得到错误:
I have created a connectionstring in mvc3 application and it is working fine in mvc views and controllers and I am able to fetch data. Now I have called the repository/model functions in a Unit Test in Test project and I am getting error:
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'.
我该如何解决呢?
推荐答案
这没有什么用MVC特别做。因为它似乎,在测试时,您使用的ConnectionString上没有'dbo.tblProduct表/视图的数据库。检查引黄联接字符串和数据库。您可能需要调试测试。
That has nothing to do particularly with MVC. As it seems, when testing, you use ConnectionString on database that does not have 'dbo.tblProduct' table/view. Check the connetion string and database. You may need to debug tests
这篇关于System.Data.EntityCommandExecutionException:执行日发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!