How to generate a SQL to Linq DBML file automatically?

learn-to
visual-studio
sql

(It Soft) #1

In this (wiki post) article we will be answering this question “How to generate a SQL to Linq DBML file automatically?”.

So here we go, All you need to do is as follows:

  1. Connect to your Database using the Server Explorer Panel.
  2. Create a new DBML file, or choose the one to use, preferably an empty DBML file.
  3. Drag the tables from your Database in the Server Explorer Panel, into the DBML file.
  4. Finally; Save your changes.
  5. And voila you have a ready to use DBML file.

As for Updating the DBML file, unfortunately there isn’t any automated method to keep your DBML file synced with your database, so you’ll have to recreate your DBML file every time you make a change to your Database structure.

Mainly Deleting the Tables and dragging them back again from the Database would do for that.

That’s it.