如何为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:\ Program文件 (x86)\ MSBuild \ Microsoft \ VisualStudio \ v12.0 \ Web \ Microsoft.Web.Publishing.targets(4270,5): 错误:"MyWebJob.Models.MyDataEntities-Web.config连接" 字符串的参数不能为null或为空.
C:\ Program档案 (x86)\ MSBuild \ Microsoft \ VisualStudio \ v12.0 \ Web \ Microsoft.Web.Publishing.targets(4270,5): 错误:"MyWebJob.Models.MoreDataEntities-Web.config连接" 字符串"参数不能为null或为空.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4270,5): Error : The 'MyWebJob.Models.MyDataEntities-Web.config Connection String' argument cannot be null or empty.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.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
- Deploy with a website project
- Deploy the webjob independently
当我将我的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文件中的
摆脱了这个问题.通常可以在\ Properties \ PublishProfiles中找到它.你可能有类似的东西:
in your publish profile pubxml file got rid of the issue. This can usually be found in \Properties\PublishProfiles. 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屋!