Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Data.EntityCommandExecutionException: An error occurred while executing th

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'.

How can i fix it?

like image 490
DotnetSparrow Avatar asked Feb 24 '23 14:02

DotnetSparrow


2 Answers

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

like image 149
archil Avatar answered Apr 26 '23 23:04

archil


Check your table may have different schema (other then dbo) change it to dbo using query below

look at this. How do I change db schema to dbo

like image 29
Zeshan Sadiq Avatar answered Apr 26 '23 23:04

Zeshan Sadiq