asp.net - LINQ to SQL Connection Strings with class library projects -
linq sql connection strings class library projects
by default, creating new linq sql model (.dbml) put connection strings in both application settings file , web.config / app.config. not of problem web projects, class library projects? have connection class can use check connection in pages have error cant read datacontext @ all.
this photo shows problem.
generally speaking, class libraries don't support config files. there ways make work, it's not considered practice since different applications may use same library interact different instances of database. recommend looking @ dependency injection or inversion of control solution ninject pass connection string constructor app references library.
update:
if absolutely must read config file assembly instead of calling application, can done configurationmanager.openexeconfiguration(). there several answers here on provide code samples doing so, i'm not going link them because encourage not go down road.
Comments
Post a Comment