- When you are using Linq to SQL, if you have your dbml in a class library project and you drag and drop a database table from the Server Explorer onto the dbml designer, VS2008 will automatically create the app.config for you which contains the connectionstring.
- If you have a web application project which references the Linq class library and you want to put the connectionstring in the web.config, here is how:
1. Remove the default constructor in the dbml designer class. Create a partial class for the datacontext class which contains the constructor to re-set the connectionstring.
3. Put the connectionstring in the web.config
'We don't want to use app.config to store connectionstring, we need to use web.config
'So we need to set the dbml's connection to none whenever new stuff has been dragged onto the design surface
Partial Public Class MyDataContext
Public Sub New()