开发者

Linq-to-SQL: how to handle database changes

I have several installations of my Linq-to-Sql app running in the field. Now I've created a new versio开发者_开发技巧n, which adds a new column to a certain table. I've added this column in the dbml file. But when updating the installation, I want to preserve the existing database. How to handle this? Linq-to-SQL doesn't seem to like this inconsistency.

Is there an easy way to update the existing database using my new dbml file?


You need to manage your database schema explicitly - that is to say that you should have creation and update of the database schema scripted so that its repeatable. For the scenario your describing I think that your application should (ideally) create and then update the database schema as required. The initial work to set this up isn't too hard and once you have the system in place making schema changes is straightforward

I wrote this up (in terms of what has worked for me for a lot of years now) at some length here:

How to create "embedded" SQL 2008 database file if it doesn't exist?

Which probably ought to be modified to take advantage of this which talks about using database extended properties:

SQL Server Database schema versioning and update

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜