none
How to Update DataContext when DB Schema changes? RRS feed

  • Question

  • It seems that the only way I can update my DataContext class def using the O/R Designer is to delete it and create it again. If I try anything less drastic, like deleting the modified table definition and then dragging the new definition onto the design surface, all heck breaks loose. Namely: the O/R designers custom tool crashes with an "unspecified error" and the DataContext disappears from the project, so the project is pretty messed up.

    Is there some better way to keep the DataContext in synch with the Database Design?
    Thursday, October 15, 2009 5:47 PM

Answers

  • Namely: the O/R designers custom tool crashes with an "unspecified error" and the DataContext disappears from the project, so the project is pretty messed up.

    In what way does it crash - does it just die without warning or does it throw an exception?

    There are third party tools for syncing up the dbml with the db (and vice versa), but nothing built in or from MSFT...

    .
    Kristofer - Huagati Systems Co., Ltd. - Cool tools for Linq-to-SQL and Entity Framework: www.huagati.com/dbmltools (VS designer add-in), www.huagati.com/L2SProfiler (query profiler for L2S)
    • Marked as answer by Yichun_Feng Thursday, October 22, 2009 1:18 AM
    Friday, October 16, 2009 1:12 AM
    Answerer

All replies

  • In the meantime I found this: http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/7604ea59-fab9-4763-93fb-589d5ff959a0/ which is dated 2007 and does have the suggestion of closing the dbml designer before doing the update. I'll try that.

    Deleting and re-creating is really awful because it deletes my partial class extensions. I find that extending the generated entity classes with other properties and methods to be quite useful. And quite upsetting when they disappear!
    Thursday, October 15, 2009 6:28 PM
  • Namely: the O/R designers custom tool crashes with an "unspecified error" and the DataContext disappears from the project, so the project is pretty messed up.

    In what way does it crash - does it just die without warning or does it throw an exception?

    There are third party tools for syncing up the dbml with the db (and vice versa), but nothing built in or from MSFT...

    .
    Kristofer - Huagati Systems Co., Ltd. - Cool tools for Linq-to-SQL and Entity Framework: www.huagati.com/dbmltools (VS designer add-in), www.huagati.com/L2SProfiler (query profiler for L2S)
    • Marked as answer by Yichun_Feng Thursday, October 22, 2009 1:18 AM
    Friday, October 16, 2009 1:12 AM
    Answerer