简体   繁体   English

用于测试/生产版本的EF6连接字符串

[英]EF6 connection strings for test/production versions

I'm sure this sounds familiar: An application is in production and connects to a live database. 我确信这听起来很熟悉:一个应用程序正在生产中,并连接到实时数据库。 Meanwhile, the next version of that application is used by developers (their own executables and a development database) and testers (test executables and a test database). 同时,开发人员(他们自己的可执行文件和开发数据库)和测试人员(测试可执行文件和测试数据库)使用该应用程序的下一版本。

In EF6, the connection string is either specified in app.config or passed in as a parameter to the DBContext constructor. 在EF6中,连接字符串要么在app.config中指定,要么作为参数传递给DBContext构造函数。 Whenever a test version is released, I need to manually replace that app.config (or the connection string) with the test version and the same needs to happen when we implement. 每当发布测试版本时,我都需要用测试版本手动替换该app.config(或连接字符串),并且在实现时也会发生同样的情况。

It seems there must be a better (automated and less risky) way of doing this, but I have not figured out what that would be. 似乎必须有一种更好的方法(自动且风险较低),但是我还没有弄清楚那会是什么。 Am I missing something elegant and built-in, or is there a best practice that I should know about? 我是否错过了一些优雅的内置功能,还是应该了解的最佳实践?

You can use XSLT transformations, or SlowCheetah . 您可以使用XSLT转换或SlowCheetah Personally I've only used XSLT transformations, and the only thing was that the app.config needs to be writeable which didn't work nice with TFS in commandline local builds. 我个人只使用过XSLT转换,唯一的事情是app.config需要是可写的,这在命令行本地版本中不能与TFS一起很好地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM