Configuring entity connection string for test AND production environments for a Winforms project.

Standard Entity Framework saves the connection string in de app.config file. This app.config file is used to create the executable.config file in which the connection string for the enity is saved. 

Unlike a web a webproject it's not possible to create different config files in a Winforms project, so this has to be done manually:

  • Make a config file: app.config.debug with connection strings for the test environment.
  • Make a config file: app.config.release with connection strings for the production environment.
  • Put this in the pre-build command: copy /Y “$(ProjectDir)App.config.$(ConfigurationName)” “$(ProjectDir)App.config”

That litle piece of code copies the debug or release config files to app.config!




Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!