Sunday, June 05, 2011

LINQ2SQL Connection Strings with class library projects

1. Set connection string in Web/App.config in main external project.
2. Open up your DBML and click the designer service. Expand the Connection property, delete Connection String and set "Application Settings" to False.
3. Open designer file and add new construtor as:
  public DataClassesDataContext()
            : base(ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString)



4. Enjoy!

Full article and inspiration exist here.

No comments: