frenchie
frenchie

Reputation: 52047

changing table name and column name in linq-to-sql

I'm using linq-to-sql to get data from my database. I want to change the name of a table and change the name of 2 columns. I know how to do that but the problem is that I've written several queries already against that table and if I change the database, the queries need to change as well.

Is there a way to make changes to the database without having to redo the queries and the datacontext?

Thanks.

Upvotes: 0

Views: 1048

Answers (3)

Pleun
Pleun

Reputation: 8920

If it is read-only queries you can also add a view to the database with the old names.

However, if it is just a couple of queries Visual Studio will very quickly show you where to make the appropriate changes (Linqs2sql is strongly typed after all). I recommend you just change all the queries and the datacontext as well becausee on the long term it will be more clear what is happening.

Upvotes: 0

Pankaj
Pankaj

Reputation: 10115

You can also call the Stored-Proc from LinQ. Write the query in your Stored-Proc to change the Schema and finally call this Proc from LINQ.

Upvotes: 0

Min Min
Min Min

Reputation: 6228

At least you need to update the mapping between your Entity and Database (Table name, Column name). All your Queries will still be the same.

The update will be from Visual studio ORM Designer(if you are using)

[OR]

With attribute in Datacontext.

[Table(Name="UpdatedName")] and [Column(Name="UpdatedName")]

Upvotes: 2

Related Questions