linq to sql add extra column to table RRS feed

  • Question

  • In a C# 2008/2010 desktop application, it uses linq to sql to point to a sql server 2008 r2 database.

    I was told by the analysis group that a new column will be added in the middle of one of the tables. The table that is being accessed is used in my *.designer.cs file.

    With the new column being added to a table, I am assuming that I will need to drag the table off of the designer surface and redrag the table back into the *.designer.cs surface to get the new column. Is this correct? (Note; my current code will not access this new code.)

    If this is not correct, can you explain your answer to me?

    Also is there a different way of how to add a column to a table that is already in the *.desginer.cs file?

    If so, can you tell me how to add the add the extra column in another method?

    Wednesday, May 29, 2013 12:07 AM


  • Hi Wendy;

    To your first question of the column being added to an existing database table and how to update the DBML file. You are correct by deleting the table and then adding it by by dragging it from the Server Explorer but I would suggest doing it in the following manner.

    1. In the Server Explorer window Refresh the schema.
    2. Delete the table from the designer that you wish to update from the database.
    3. Save the designer back to the file system.
    4. Drag the table from the Server Explorer onto the designer and save one more time.
    5. Recompile and you should be fine.

    As far as the second question I do not know if it is possible.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, May 29, 2013 1:12 AM