generating .dbml using SQLMetal

2.1k views Asked by At

I'm new to LINQ to SQL. I have tried Object Relational Designer(O/R Designer) Approach to generate classes and worked well. But, I wondering is there any way I can generate the same .dbml file for my database using SQLmetal tool. can anyone please send me the command to fire. I just want to use SQLmetal command against my database and everything should be place to go.

Is it also possible to create separate class file each table and views in database as It will be helpful to handle in Visual Studio.

2

There are 2 answers

1
BlackR2D On

Try:

sqlmetal --server={server} --database={db} --user={user} --password={pass} --namespace={namespace-you-want-may-be-empty} --entitybase={dbobject-if-you-need-a-base-class-may-be-empty} --generate-equals-hash --pluralize --culture=en --dbml=dblinq.dbml

0
Ahmed On

Simply run these two commands

SqlMetal /server:<server> /database:<db> /dbml:<file>.dbml
SqlMetal /server:<server> /database:<db> /code:<file>.designer.cs