The application implements the MVC pattern and works with a database (MS SQL Server). Business logic is implemented in a separate project as a class library, the ADO.NET model is also located there, methods for accessing the database, the connection string is added to the parameters and spelled out in app.config. The Database First model was used.

With this construction, the application cannot query the database, the error "Could not find the connection string with the name ... in the application configuration file" appears. I understand that the application is looking for the connection string in the project's App.config file, where the Controller and View are implemented. And there it is not, because it is in the class library project where Model is implemented. How to solve this problem?

    1 answer 1

    The application searches for the connection string in the file <name of the file being run> .exe.config. Determine which project you are running, you need to copy the connection string to this project in the app.config file, compile and run.