views:

200

answers:

2

This is a similar problem to this question

When I deployed my dev app to the prod server I was getting an error:

System.Data.SqlClient.SqlException: Invalid object name 'dbo.Login'.

The table attribute on the linq mapping looks like [Table(Name="dbo.Login")]

When I loaded the prod db schema into the vs2008 server explorer and refreshed my dbml entirely with that one, the application on prod works, but now the application on dev does not work.

The table attribute on the linq mapping now looks like [Table(Name="prodDbUsername.Login")]

On the dev server I now get

System.Data.SqlClient.SqlException: Invalid object name 'prodDbUsername.Login'.

What is the best way to manage these different user prefixes between dev and prod?

+2  A: 

It sounds like you have have identical tables named differently in your different environments. The simplest way to fix your problem is to use identical schema for all environments (the data can be different, but you are asking for all kinds of problems if the schema is not the same).

EDIT: With your further clarification, the tables are being created either with a different owner or a within a different schema. See http://www.sqlteam.com/article/understanding-the-difference-between-owners-and-schemas-in-sql-server for further clarification on the difference.

I would recommend that you try creating your tables with the following syntax:

CREATE TABLE [dbo].[MY_TABLE_NAME]...
sestocker
I created the prod db with a script from the dev. There are no differences between the tables, cols or fk relationships.
CRice
It seems to me that the production environment (hosting company) wont allow referring to a table via dbo.Tablename and it must be via dbuser.Tablename
CRice
The article was helpful thanks. I created a schema on the dev db eg. 'prodDbUserName', then ran [sp_changeobjectowner 'dbo.Login', 'prodDbUserName'] on each table. So now the dev copy has the same table prefix, so both prod and dev work with the same dbml.
CRice
+1  A: 

If you're using a single schema (i.e. not multiple schemas in a single db), you can just remove the schema prefix on your tables.

E.g. change:

<Table Name="dbo.person" Member="Persons">

To:

<Table Name="person" Member="Persons">
KristoferA - Huagati.com