Question

I tried to find some information in topic: EntityConnection error The specified named connection is either not found in the configuration

Now I found another solution - to open .config file and create key in connectionstrings. But my question is that - Entity Model add connectionstrings to app.config file. ConfigurationManager.OpenExeConfiguration open myApplication.exe.config file.

  • is it possible to change that application will use myApplication.exe.config ?
  • or maybe there is way to open app.config file and add connectionString?
Was it helpful?

Solution

Use OpenMappedExeConfiguration in combination with ExeConfigurationFileMap to specify the file name:

ConfigurationManager.OpenMappedExeConfiguration(
   new ExeConfigurationFileMap() { ExeConfigFilename = "your file path here" }, ConfigurationUserLevel.None);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top