我正在使用EF Code-First Migrations:https://msdn.microsoft.com/en-us/data/jj591621.aspx。在VS的Package Manager Console中使用
我还在使用SlowCheetah来管理我们拥有的不同环境,特别是管理每个开发人员都有自己的数据库副本,以便他们可以更新模型更改而不会将其他人锁定在数据库中。因此,一个变化的配置值是目标数据库名称。
(由于某些原因,我们没有像这样使用
包含模型和迁移的项目是
如果我手动更改
但是,如果我设置SlowCheetah转换以修改给定构建配置的值,选择该配置,重建代码,然后运行迁移,则不应用转换;它使用基本
总体而言,SlowCheetah工作正常 - 当我运行sln以获取网站时,它使用由VS Build Config确定的正确Db。
有什么想法吗?
编辑:
ConfigFile:
转换功能:
add-migration
,update-database
等命令。我还在使用SlowCheetah来管理我们拥有的不同环境,特别是管理每个开发人员都有自己的数据库副本,以便他们可以更新模型更改而不会将其他人锁定在数据库中。因此,一个变化的配置值是目标数据库名称。
(由于某些原因,我们没有像这样使用
connectionStrings
.config
设置,而是将DB名称放在appSettings
块中)包含模型和迁移的项目是
TheCustomer.Database
项目。如果我手动更改
TheCustomer.Database/app.config
中的appSetting
值并运行迁移,则会正确使用配置值 - 因此,配置基本上是有效的。但是,如果我设置SlowCheetah转换以修改给定构建配置的值,选择该配置,重建代码,然后运行迁移,则不应用转换;它使用基本
app.config
中的值,而不是app.SelectBuildConfig.config
。总体而言,SlowCheetah工作正常 - 当我运行sln以获取网站时,它使用由VS Build Config确定的正确Db。
有什么想法吗?
编辑:
ConfigFile:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<appSettings>
<add key="DbName" value="This Default Value shouldn't work - you should be using a value for a specific build" />
<add key="DbPassword" value="SomePassword" />
</appSettings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>
转换功能:
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="DbName" value="LocalDev_MDM" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>
</configuration>
update-database
。 - Brondahl