Search code examples
linq-to-sql

Add column to the database - how do I update the dbml file?


Is there a way I can refresh the dbml file or do I have to delete it and generate a whole new one?


Solution

  • So far as I know there's no built-in functionality in the designer to update a table with changes in a database.

    There are third party tools (http://www.huagati.com/dbmltools/) that offer that sort of functionality.

    Whenever I ran into this issue it was on the order of one or two columns on a table with multiple manual relationships already set up, so I just edited the XML (right click on the DBML and select open with -> XML) and added the columns to the table definition.

    When DBML file is saved the associated .designer.cs file is automatically updated with code for newly added columns. Therefore, there is no need to drop and recreate table in designer mode.