davioooh
davioooh

Reputation: 24706

Change table name in database and maintain association with Linq

I'm using LINQ to SQL to connect to my database and mapping tables to object.

Now I'd like to change the name of a table in my DB, but replacing it in my dbml file I also have to replace the new name in so many places in my application that... uhmmm

So I'm wondering - Is it possible to change the name of a table in database and automatically reflect the changes in code? Is there any refactor utility to obtain this?

Upvotes: 0

Views: 965

Answers (1)

Gert Arnold
Gert Arnold

Reputation: 109253

I don't know how you would imagine this to work. I can't really. Suppose you'd rename table Product to let's say Produce. How would an automated tool know that the table is renamed and not deleted while a new table happens to have been added?

If you want to rename a database table and keep it mapped to a class having its previous name, the only thing you can do (that I know of) is change the table name in the dbml file:

enter image description here

Upvotes: 1

Related Questions