LINQ - refresh dbml when stored procedure are changed in database

Asked By harsh shah on 21-Jun-11 01:47 AM
Hi ,

Good Morning.

how to refresh dbml file when change in a database.

here not shows me a refresh option in dbml file  on right click of mouse.

also not run a custom tool .

so please help me how to refresh a dbml file.


Regards,

Harsh Shah
Kirtan Patel replied to harsh shah on 21-Jun-11 01:53 AM
you need to re drag drop the stored procedure again into dbml designer interface to do that

delete the previous stored procedure shown in DBML Designer and re drag drop it


Reena Jain replied to harsh shah on 21-Jun-11 01:56 AM
hi,

There's no built-in way to sync the dbml file/datacontext with the database after making changes (besides regenerating the entire dbml file by removing all or a selection of the entities and re-dragging them, or by using sqlmetal as suggested by other replies),

If you have added new tables to the datbase you can simply drage them into the designer window. If you have added or changed fields on existing tables or altered foreign keys/relationships, your best bet is to manually edit the classes and properties in the DBML file. ~You can delete them and the drag them back in from server explorer which will refrech them from the datbase but you will lose any custom modifications you have made such as changing properties from public to protected or setting up inhertance or other things.

There are third-party tools that add refresh functionality to the Visual Studio L2S designer.

One such tool is my add-in, Huagati DBML/EDMX Tools. You can download it from http://www.huagati.com/dbmltools/ and get a trial license if you want to take it for a test spin.

Hope this will help you


harsh shah replied to Kirtan Patel on 21-Jun-11 02:08 AM
Hi,

Thanx.

That's Right.

it's good for 2 or 3 Stored procedure

but i change in  Stored procedure and add some column in  table that time i think this method is difficult to implement.

so any other way to refresh a .dbml file

Regards,

Harsh Shah
Kirtan Patel replied to harsh shah on 21-Jun-11 02:12 AM
sure there is another way to do this cumbersome task you can use below visual studio addin to do that visual studio it self does not have this refresh functionality

you can use this Addin to Synchronize DBML with database

http://www.huagati.com/dbmltools/


thanks

Riley K replied to harsh shah on 21-Jun-11 09:19 AM
There is no automated mechanism for this

There are three ways to keep the model in sync.

  1. Delete the modified tables from the designer, and drag them back onto the designer surface from the Database Explorer. I have found that, for this to work reliably, you have to:

    a. Refresh the database schema in the Database Explorer (right-click, refresh)
    b. Save the designer after deleting the tables
    c. Save again after dragging the tables back.

  2. Use SQLMetal to regenerate the schema from your database. I have seen a number of blog posts that show how to script this.

  3. Make changes directly in the Properties pane of the DBML. This works for simple changes, like allowing nulls on a field.

Thanks