Making Linq operations to a database in Data Connections
I am using Visual Studo 2012 and SQLExpress.
I am attempting to make Linq operations to a database in Data Connections. The database is on a local server on my computer. It already shows up in the Server Explorer -> Data Connections pane.
How do I actually obtain the data source to make operations against it in my program?
You have to add the Linq-to-SQL entity objects. In Visual Studio:
- Right click on your project and Add Item
- Add the LINQ to SQL Classes under Data
- Open the new DataClasses.dbml project file in VS
- Drag database objects (tables, stored procedures) onto the pane
- In your code, instantiate the DataContext class, and you're good to go.