LINQ: Using SqlMetal with VS Express

There are quite a few of us that don’t have the luxury of sitting with Visual Studio 2008 and rightfully so many of us make use of the Express editions. Heres the problem though: What happens you want to generate a DBML file for a database that does not reside on your local machine and you cannot access the mdf and ldf files directly?

You use SqlMetal! SqlMetal is the tool used by LiNQ and VS to generate your DBML files. The good news is that you can use this manually! To generate the DBML file for a database on the server you simply to the following:

Step 1:
Open a command prompt and navigate to “C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\”

Step 2:
Make sure you have a connectionstring handy to copy

Step 3:
Run the following command at the prompt –> SqlMetal /conn:”connectionStringHere” /dbml:DatabaseName.dbml

And thats it! Obviously where I’ve entered “connectionStringHere” you need to enter your connection string between the inverted commas and where I’ve said DatabaseName.dbml you can enter the name you want for you DBML file.

Once this is done you can simply include this DBML in your Express Project and all the will generated as per normal procedure. What does confuse me however is why Microsoft gives us this file but doesn’t implement its full use in the express editions. It makes no sense to me!

Posted under Development, LiNQ by StevenMcD on Tuesday 15 January 2008 at 7:45 pm

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment