如何为 WebJob 项目设置连接字符串? [英] How do I setup Connection Strings for a WebJob project?
问题描述
我正在尝试设置网站和 webjob,但每次尝试独立于网站发布 webjob 时都会出错(即从上下文菜单中选择 Publish as Azure WebJob
)
I am trying to setup a website and webjob, but get an error everytime I try to publish the webjob independently of the website (i.e. Selecting Publish as Azure WebJob
from the context menu)
C:程序文件(x86)MSBuildMicrosoftVisualStudiov12.0WebMicrosoft.Web.Publishing.targets(4270,5):错误:'MyWebJob.Models.MyDataEntities-Web.config 连接String' 参数不能为 null 或为空.
C:程序文件(x86)MSBuildMicrosoftVisualStudiov12.0WebMicrosoft.Web.Publishing.targets(4270,5):错误:'MyWebJob.Models.MoreDataEntities-Web.config 连接String' 参数不能为 null 或为空.
C:Program Files (x86)MSBuildMicrosoftVisualStudiov12.0WebMicrosoft.Web.Publishing.targets(4270,5): Error : The 'MyWebJob.Models.MyDataEntities-Web.config Connection String' argument cannot be null or empty.
C:Program Files (x86)MSBuildMicrosoftVisualStudiov12.0WebMicrosoft.Web.Publishing.targets(4270,5): Error : The 'MyWebJob.Models.MoreDataEntities-Web.config Connection String' argument cannot be null or empty.
部署 WebJob 有两种选择
There are two options for deploying a WebJob
当我将我的网络作业链接到网站项目时,它会随网站一起部署而不会出错.但是,当我尝试独立部署它时,我的控制台和错误列表中出现上述错误,但仍然部署了 webjob.
When I link my webjob to a website project, it deploys with the website without error. However, when I try to deploy it independently I get the above error in my console and Error List, but the webjob is still deployed.
如何独立部署我的 webjob 并摆脱这种持续存在的错误"?
How can I deploy my webjob independently and get rid of this persistent "error"?
推荐答案
我发现为
<Destination Path="" />
在您的发布配置文件 pubxml 文件中解决了该问题.这通常可以在 PropertiesPublishProfiles 中找到.你可能有类似的东西:
in your publish profile pubxml file got rid of the issue. This can usually be found in PropertiesPublishProfiles. You probably have something like:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Context" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Context, DAO" MigrationConfiguration="Context.Migrations.Configuration, DAO" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
将其更改为以下为我修复了它:
Changing it to the following fixed it for me:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Context" Order="1" Enabled="False">
<Destination Path="{deployment connection string}" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Context, DAO" MigrationConfiguration="Context.Migrations.Configuration, DAO" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
希望对您有所帮助.
这篇关于如何为 WebJob 项目设置连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!