0

I was given a console app to be moved to a different server. I also need to move tables used by this application to a different server/database. The new database has a different name. The app was converted I believe from VS2005 to VS2010 before me some time ago. I changed the connection string in the app config. This project contains entity model. I noticed in one of the auto generated model files this line: [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="OldDatabaseName")]

This is an autogenerated file. Is there a way to not reference the old database without recreating the model and rebuilding the app? Thank you, Jenny

Boroda
  • 195
  • 1
  • 7
  • 23

1 Answers1

0

Assuming the underlying tables have the same names, structures and constraints, all you would need to do is change the connection string in the configuration file and this generated file to point to the new database.

It is also worth changing the database properties of the .edmx file to ensure it is consistent with the above, in case you do regenerate the file.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Thank you for your reply. I checked, the properties of the .edmx file use the connection string from the config file. I'm not planning to regenerate the model. I just want to make sure the model is referencing the new database. If I understand correctly, I could just ignore the [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="OldDatabaseName")] line since I already changed the connectiohn string. Is my understanding correct? – Boroda Aug 02 '12 at 16:02
  • @Boroda - I think it is safer to _also_ change the name in that line (as it would be the default database name otherwise). – Oded Aug 02 '12 at 16:07