好的,所以我做了蠢事并发布了针对我们的开发数据库(SQL Server 2008 R2)的生产代码(C#,VS2010).幸运的是我们还没有使用生产数据库,所以我没有尝试恢复和同步一切的痛苦......
但是,我想要防止这种情况再次发生,因为它可能会更加痛苦.我的想法是添加一个我可以在启动时查询的表,并通过返回的值确定我连接的数据库.例如,生产将返回"PROD",dev和test将返回其他值.
如果它有任何区别,应用程序会与WCF服务进行通信以访问数据库,因此我在配置文件中有端点,而不是实际的连接字符串.
这有意义吗?其他人如何解决这个问题?
谢谢,戴夫
您可以从命令行调用“慢猎豹”吗?我希望添加一个后构建事件,以针对各种不同的环境转换我的配置文件。
干杯迪
你能用同样的方式对另一个文件如connections.config,nlog.config,app.config进行web.config转换吗?我似乎无法找到答案.
<connectionStrings xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<add name="ApplicationServices" connectionString="Data Source=ConnectionString" xdt:Transform="SetAttributes(mode)"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud) 我喜欢SlowCheetah的原因,但是在我的app.config中使用它来转换端点时遇到了一些问题.我希望也许有人可以看一看,看看我错过了什么,或者过去曾经遇到过这个问题.
app.config默认
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/RFPModel.csdl|res://*/RFPModel.ssdl|res://*/RFPModel.msl;provider=System.Data.SqlClient;provider connection string="data source=developmentServer;initial catalog=databaseName;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMasterEngineService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://DevelopmentServer/WebServices/MasterEngine/MasterEngineService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMasterEngineService" contract="OverlayFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
</client>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Release for Release是:
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations …
Run Code Online (Sandbox Code Playgroud) slowcheetah ×4
wcf ×2
app-config ×1
asp.net ×1
database ×1
msbuild ×1
sql-server ×1
version ×1
web-config ×1