c# - How can I configure entity framework to use a different connection string depending on its environment? -
this question has answer here:
my company uses different databases depending on stage of development project in. i'm trying push adoption of entity framework + linq have hit stumbling block when asked how work across our multiple environments.
they under impression have manually changed each environment , take forever deploy.
how configure ef database-first use different connection on dev, test, , production servers?
can set sort of variable? there option missed?
edit: possible duplicate of managing debug , release connection string
you can specify connection string application uses using app.config or web.config file, depending on type of project you're using.
read great documentation: http://msdn.microsoft.com/en-us/data/jj592674
for database-first application using ef, here's sample app.config:
<configuration> <connectionstrings> <add name="northwind_entities" connectionstring="metadata=res://*/northwind.csdl| res://*/northwind.ssdl| res://*/northwind.msl; provider=system.data.sqlclient; provider connection string= "data source=.\sqlexpress; initial catalog=northwind; integrated security=true; multipleactiveresultsets=true"" providername="system.data.entityclient"/> </connectionstrings> </configuration>
you can use different app.config during debug , release (here's instructions http://mitasoft.wordpress.com/2011/09/28/multipleappconfig/), makes easy ef pick different config in different environments.
Comments
Post a Comment