问题描述
应用任何命令时
- 更新数据库"
- 添加迁移"
EF使用主要web.config中的连接字符串
The EF uses the connection string in your main web.config
即使您已使用xml转换配置了web.debug.config和web.release.config
even if you have configured web.debug.config and web.release.config with xml transformation
这意味着,我不得不冒险忘记发布真正的web.config
,然后再发布.
This means, I have to go in and risk forgetting to change my true web.config
back prior to a release.
推荐答案
我认为在本地运行web.config转换的唯一方法是使用带有以下参数的MSBuild,其中[YourTransformationConfiguration]是要使用的配置的名称,例如调试或发布:
I think the only way to run web.config transformations locally is to use MSBuild with the following parameters, where [YourTransformationConfiguration] is the name of the configuration to use, e.g. Debug or Release:
msbuild PathToProject /T:Package /P:Configuration=[YourTransformationConfiguration] /P:AutoParameterizationWebConfigConnectionStrings=False
其输出将在以下位置提供:
The output of which will be available at:
[ProjectFolder]\obj\[YourTransformationConfiguration]\Package\PackageTmp
从此处,您可以在程序集上运行migration.exe,这与运行Update-Database PowerShell脚本类似.如果您使用了Nuget,它将位于EntityFramework软件包的 tools 文件夹中.我在启动和运行时遇到了一些麻烦,但是这里有一个有用的答案Stack Overflow答案:
From here you can run migrate.exe on your assembly, which is similar to running the Update-Database PowerShell script. If you used Nuget, this will be in the tools folder of the EntityFramework package. I had some trouble getting this up and running, but there's a useful answer Stack Overflow answer here:
这篇关于如何使实体框架迁移使用web.config转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!