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:
Connect to your Database using the Server Explorer Panel.
Create a new DBML file, or choose the one to use, preferably an empty DBML file.
- Drag the tables from your Database in the Server Explorer Panel, into the DBML file.
- Finally; Save your changes.
- 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.