
 February 18, 2016 19:59 by 
 Peter
 PeterI'm simply getting to grips with MVC linq etc and came across what sounds like a standard stumbling block. All the tutorials are either Code first examples or they create the information from scratch within the App_Data directory. All well and smart for a tutorial that require to be simply moveable to the readers computer, however not very useful when putting in a full scale MVC application. My first problem was my lack of knowledge of Linq to SQL. Finally, how to add an external SQL database to your MVC project:

- Right click on "Models" folder, choose "Add New Item"
- Add a "Link to SQL Classes" item
- Open your "Server Explorer" pane (if you cant see it attempt "View" on the menu bar and "Server Explorer"
- Right click on "Data Connections" and choose "Add Connection"
- Follow the instructions.
- almost there....
- Expand your newly added database to look at the tables.
- Drag the tables you wish over to the main pane of the "Link to SQL Classes" item you added at the start.
- Hey presto, you have a database context you'll run Linq queries against.
Please bear in mind you will need to use the "Models" namespace to reference you database context objects.
And now back to highly sophisticated programming!
HostForLIFE.eu ASP.NET MVC 6 Hosting
HostForLIFE.eu        is European Windows Hosting Provider which focuses on Windows      Platform   only. We deliver on-demand hosting solutions including  Shared     hosting,   Reseller Hosting, Cloud Hosting, Dedicated  Servers, and  IT    as a  Service  for companies of all sizes. We have  customers from    around  the  globe,  spread across every continent. We  serve the  hosting   needs  of the   business and professional,  government and  nonprofit,    entertainment and   personal use market  segments.
