aherrick
aherrick

Reputation: 20169

Use SQL Server CE Locally and SQL Server 2008 on Production Entity Framework Code First?

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?

Upvotes: 3

Views: 123

Answers (2)

Jens H
Jens H

Reputation: 4632

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.

Upvotes: 1

IndigoDelta
IndigoDelta

Reputation: 1481

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!

Upvotes: 1

Related Questions