Tilt-logo

Things I Learned Today - our daily eureka-moments

Carr
proppi
Edland
feenyx
Programming .NET VS2010 Web Windows VS2012 S3 Search SQL SqlMetal Accessibility Amazon Android App BBQ EBS EC2 Exchange Food Garmin Geocaching GPS Grill Java Linq Lucene MVC PowerShell

Adding remote SQL servers as data sources in Visual C# 2010 Express - Carr, 06.09.2011

My winforms app was going to speak Linq to SQL with an existing remote SQL server. Using Visual Studio C# 2010 Express, I assumed this was a piece of cake, and proceeded to add the server as a data source...

Image

Files? Really?

It turns out that Express doesn't think you will need to speak to actual servers, being a hobbyist/prototyping environment and all. This stackoverflow thread sums it up nicely.
The solution? Screw the database explorer and use SqlMetal.exe!

In my case:
sqlmetal.exe /server:myServer /database:myDatabase /user:myUser /password:myPassword /dbml:myContext.dbml /pluralize

This resulted in a nice and clean .dbml file which I could simply drop into the project folder, and then..


myContext context = new myContext(myConnectionString);
myThing thing = new myThing();

context.Things.InsertOnSubmit(thing);
context.SubmitChanges();



Win.
Tags: Programming .Net VS2010 SQL Linq SqlMetal
Comments:
Nobody has commented on this post yet. Feel free to be the first!