I have a MVC 4 application using Sql Server 2012 localDB. Inside the application I am using EntityFramework to access data. I have one raw sql command executing as 'select something from [databasename].[dbo].[something]'. This query works absolutely fine when running through visual studio. But when deployed on IIS 7 for the same query I get an error 'invalid object name'. Rest all queries and EF commands works fine. I realized that this is due to me qualifying the query with database name. But due to some valid reasons, I need to have databasename in this particular query. Please help!!!
Asked
Active
Viewed 377 times
1 Answers
0
Is the DB you are trying to connect to on the same server? Is it linked? I am thinking not and that is why you need to qualify the query.
If on a different server you need [servername].[databasename].[dbo].[something] and you need to link to the other server.

Guy Nethery
- 299
- 1
- 7
-
yes it is on the same server. Can you please elaborate on the linked part? – Nik Feb 12 '14 at 20:04
-
If both databases are on the same server then you don't need to link them. That applies DB on different servers. Do you deploy the same DB connection string(s) or is the other DB on a different instance? – Guy Nethery Feb 12 '14 at 20:14