Problem refreshing tables in the LINQ to SQL designer

后端 未结 9 1383
野趣味
野趣味 2021-02-08 12:54

I have been using LINQ to SQL for a while, and there is one thing that has always bothered me. Whenever I modify the schema of a table, in order to refresh it in the designer, I

相关标签:
9条回答
  • 2021-02-08 13:26

    I don't do any customization of the content on the designer so after table changes I just hit CTRL+A followed by DEL. Then shift-select all of my tables and slap them back onto the designer. I don't have 100s of tables yet so not sure if things slow down at some point but with 20+ tables it just takes a second.

    0 讨论(0)
  • 2021-02-08 13:30

    There are a couple of other options:

    1. Edit the .dbml file that the designer uses to draw the tables and generate the code. I've used this approach when the changes are small (adding a couple of columns, creating a simple table)
    2. Use sqlmetal to create the required xml for the changed tables and move the declarations by hand to the .dbml file. This one is better for when the changes are either more complex or larger.
    0 讨论(0)
  • 2021-02-08 13:33

    I have written an add-in that can do that (in both directions; database -> DBML or DBML- -> SQL-DDL diff script).

    Unlike SQLMetal (or EF's "update model from database") mentioned in another reply, the add-in does a true sync/refresh; applying changes corresponding only to the differences between the model and the underlying db.

    That means any customizations (renamed properties/navigation properties etc) that you have made in other areas of your model will not be removed/overwritten unless they are in conflict with the underlying db schema. (in which case you can still preserve them by adding them to the add-in's "exclusion list")

    You can download it and get a free 30-day trial license from http://www.huagati.com/dbmltools/

    0 讨论(0)
提交回复
热议问题