Refresh dbml when database schema changes

Last post 05-16-2008 11:40 PM by pbz. 2 replies.

Sort Posts:

  • Refresh dbml when database schema changes

    03-07-2008, 3:19 AM
    • Loading...
    • PaulLinton
    • Joined on 05-17-2007, 12:16 AM
    • Posts 6

    Hi,

     I have a .dbml file that I have dragged several tables on to from a database in the Server Explorer.  I have written a lot of code against the model that was created.

    Now I have added another table (Companies) to the database and a Foreign Key in one of my existing tables (People) which references the PK of the new table.  I have refreshed the Server Explorer and can see the new table and the new FK in my existing table.  I can drag the new table on to the dbml workspace, no problem.  But how do I make the new FK appear in the dbml class?  I have tried right-clicking on the .dbml file in the Solution Explorer and choosing "Run Custom Tool" but that doesn't do anything.  I suppose I could just delete the .dbml file and start all over again, but surely there is a better way!  Eventually there will be dozens of tables involved and recreating every time one column changes in one table would be very painful.

    Please tell me that I am overlooking something simple.

    As a matter of interest, what if I went the other way and added or modifed a class in the dbml, can I get the database schema updated?

    thanks in advance

    Paul

    Filed under:
  • Re: Refresh dbml when database schema changes

    03-09-2008, 10:42 PM
    Answer

    Hi PaulLinton,

    As far as I know, you're unable to update the database scheme in LINQ designer - that's meaning you have to modify the scheme in designer when your table scheme in database changes. Image that you've changed the scheme of table A in database, you don't need to delete all the tables and re-drag them from database. You just have to delete table A and re-drag it onto the designer - if need, create the FK associations. It's very easy for you when facing the scheme changing.

    Another thing I recommend is - you could implement the validation and logic in partial class. LINQ supports partial validation and logic which gives your application a high flexibility. In this case, you don't need to re-write the validation and logic when the scheme changes. It will save you much time. 

     

    Hope this helps you! 

    Sincerely,
    JanIvan Qian

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
  • Re: Refresh dbml when database schema changes

    05-16-2008, 11:40 PM
    • Loading...
    • pbz
    • Joined on 05-26-2007, 5:20 PM
    • Atlanta, GA
    • Posts 141

    Let me just say that this is pretty unbelievable (thinking of less PG13 words) that this is not built in. When more than one person works on the database am I supposed to guess what changed?! Or you all live in a perfect world where everything is documented and the database is created once and it's never changed?! Even the crappy Crystal Reports editor has a verify database that allows you to sync with the database schema! This should have been the FIRST feature to implement in the designer. Will you guys stop churning out crap, slow down, and polish things?! Arrrrrr Angry

Page 1 of 1 (3 items)