How to pass a connection string to a class library?

I have a project structure like

MySolution
    -FrontEnd
         -webforms
         -console
         -Mvc
    -Repositories
         -Dapper   (Class library)
    -Tests

How to reference the connection string in my repository class library? I tried to add App.Config to my class library project, but it is not available in Add New Elements. I am using Visual Studio 2013 Express for the web. Thanks Damien.

+4
source share
2 answers

.Config, which applies to libraries, is an execution assembly using these libraries, so you do not need to add App.Config to your project, it will use the App or Web.Config of your startup project.

ConfigurationManager, System.Configuration .

+5
+2

Source: https://habr.com/ru/post/1523850/


All Articles