DotnetSparrow
DotnetSparrow

Reputation: 27996

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?

Upvotes: 4

Views: 16992

Answers (3)

Moe
Moe

Reputation: 197

Its very strange for my case, as it is required to do mapping between model and tables, the name has to be the same. When I added 's' at the end of table's name, it works. I don't know if this part work of what LINQ does.

Upvotes: 0

Zeshan Sadiq
Zeshan Sadiq

Reputation: 21

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

Upvotes: 2

archil
archil

Reputation: 39491

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

Upvotes: 6

Related Questions