-1

I am building a Windows Form (WinForm) using Entity Framework 6, I should have 2 different connection strings.

  1. a connection string for development mode.
  2. a connection string for deployment.

how can I achieve that and easily switch between them?

  • 1
    Have a look at this comprehensive answer: https://stackoverflow.com/a/5109530/594832 – Jan Köhler Nov 30 '19 at 09:51
  • just did, couldn't find my requirement. –  Nov 30 '19 at 10:01
  • It exactly describes what you'll have to setup. It's basically what omgGenerics wrote in his answer. But his answer relates to a web project. As you're developing a WinForms-app you'll have to do a little extra-effort because config-transformation isn't as built-in WinForms projects as it is in web projects. And exactly this is explained in the linked answer :-) – Jan Köhler Nov 30 '19 at 10:11
  • it is not only about web or winform, using EF6 must be considered too. –  Nov 30 '19 at 10:12
  • I understand you're asking for EF. But this isn't an EF-specific question. You'll find yourself often having to change config values depending on a certain deployment environment. Maybe you'll have to - as in your case - change a connection string, maybe you'll have to change another setting. All this can be achieved with "config transformation". There's another link to a quite old blog post in the answer which describes all this in even more detail. Maybe this is more helpful for you :-) https://web.archive.org/web/20120220074748/http://olegsych.com/2010/12/config-file-transformation/ – Jan Köhler Nov 30 '19 at 10:18
  • @ZeroOne What *exactly* is the problem? What keeps you from deploying the deployment connection string? – Gert Arnold Nov 30 '19 at 11:33
  • @GertArnold I need this scenario to check if the Application is still in development mode (DEBUG), use the first connection string and if it is deployed, then use the second one. –  Dec 01 '19 at 12:33
  • 1
    The answers linked to in the first comment gives tons of tips. I can't believe that none of them is applicable to you. If you don't try anything we can't guess where you're stuck. – Gert Arnold Dec 01 '19 at 12:40

1 Answers1

1

just use a tool called SlowCheetah

https://marketplace.visualstudio.com/items?itemName=vscps.SlowCheetah-XMLTransforms&ssr=false#qna

  • 1
    At Stack Overflow, link-only answers are deemed "not an answer" because the link may break, rendering the answer useless. Answers should at least summarize the useful part of the link in a bit of code. FYI this same answer was given before and deleted by moderation. – Gert Arnold Dec 02 '19 at 19:46