I am using EF Code first to generate my models. I have added SQL Server Compact Edition to my project and am using that as a DB locally.
I want to configure the DataContext so that when I push to Production (based on the machine name) it instead would pull from a connection string in the Web Config and use a SQL Server 2008 DB.
What is the easiest way to do this? Basically my question is at what point do I need to add the conditional so that when it is deployed it pulls in the connection string and just works.
Is this even a recommended approach?
This discussion has one approach where you have multiple settings in the same config file. Here the suggestion is to use multiple config files, one for each environment or use MSBuild to produce select a config file.
using #IF DEBUG is another option but risky where a developer decides to test a release version and forgets they are running against a live system!
My first thought is that you only need to deliver a different ConnectionString when you deploy your App.Config
Using different 'Solution Configurations' (Debug/Release/ etc.) there are possibilities to even automate this via with MSBuild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With