Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entity Framework Perplexities
Message
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Network:
Windows Server 2012
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01646424
Message ID:
01646508
Views:
24
Thanks Viv. But I have reasons to believe that this Transform logic does not apply to app.Config (Desktop Applications).
There is no Transform Preview on the rightclick menu even after I implement the tranform markups.

I'm now looking for ways where I can change the connection parameters in real time, before I connect (I.e. before I instatiate the DBContext). My workstation is a portable pc , and based on the wireless I determine "where I am", and based on that I want to inject the connection parameters at runtime (production sql server in the office ; or sql server on my local machine anywhere else).

Wish me luck.

>>>
>>>I usually create a custom configuration (although you might be able to use the standard 'Debug' and 'Release' configurations) and use web.config transforms. Little bit of work setting up but well worth it once in place since you only have to change 'common' settings in one place. See:
>>>https://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx
>>
>>Many thanks. As always.
>>
>>I guess the same logic would apply to app.config.
>>
>>It's not exactly what I was looking for, but it does give me some clue of how to proceed.
>
>It's pretty straightforward. If you can use, say, the standard release config to change the default then it should just look like this:
<?xml version="1.0"?>
>
><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
>   <connectionStrings>
>      <add name="PGSheetControlEntities" connectionString="metadata=res://*/PGSheetModel.csdl|res://*/PGSheetModel.ssdl|res://*/PGSheetModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=192.168.0.15;Initial Catalog=PGSheetControl;User ID=sa;Password=xxxxx ;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"
>        xdt:Transform="Replace" xdt:Locator="Match(name)"/>
>  </connectionStrings>
></configuration>
i.e. copy the default entry for the 'add' attribute, change the Data Source (and any other parameters that are different and add the xdt:Transform attribute. You can right click on the release config and use 'Preview Transform' to confirm that everything is correct.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform