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.

enter image description here

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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -