Best way to update LINQ to SQL classes after database schema change

前端 未结 7 2022
别那么骄傲
别那么骄傲 2020-11-29 16:08

I\'m using LINQ to SQL classes in a project where the database design is still in a bit of flux.

Is there an easy way of synchronising the classes with the schema, o

相关标签:
7条回答
  • 2020-11-29 16:35

    Here is an easy fix without any additional software, that just works for simple changes (like added fields, few tables, etc).

    Instructions:

    • You pull a copy of the changed table into the designer (will be removed later)
    • Now select all the new (or changed) fields and (right-click ->) copy
    • In your original table right click and insert them (delete changed fields first)
    • Now delete the table you copied them from

    I know it is kinda obvious, but somehow non-intuitive, and it helped me a lot, since all the right attributes and types will be copied, and all links stay intact. Hope it helps.

    When to use:

    Of course it is - as said - for small changes, but surely better than manually replacing tables with many links, or when you don't want your whole database structure generated by SQLMetal. For example when you have a big amount of tables (e.g. SAP), or when using cross-linked tables from different databases.

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