Asp.net mvc 5 Asp.Net EF代码首次与VSTS连续集成-Azure Sql Db未部署
我在运行迁移以创建/更新托管在Azure上的Sql Db时遇到问题。它们在本地运行良好,但在发布到Azure时似乎完全被忽略 详情: -Asp.NETMVC5.2.3 -实体框架6.1.3 -Visual Studio团队服务(联机) -Azure Web App和Azure SQL Db(在Imagine/Dreamspark订阅下) 我创建了一个不同的应用程序,它不使用CI,但在VisualStudio中使用了发布功能,它发布得很好,而且工作正常。我已经从Azure中删除了该web应用程序&db,因为订阅只允许一个db 我想这可能是我在VSTS中设置构建定义时缺少的东西,我只是不确定是什么 我试过:Asp.net mvc 5 Asp.Net EF代码首次与VSTS连续集成-Azure Sql Db未部署,asp.net-mvc-5,azure-web-app-service,entity-framework-migrations,azure-pipelines,dreamspark,Asp.net Mvc 5,Azure Web App Service,Entity Framework Migrations,Azure Pipelines,Dreamspark,我在运行迁移以创建/更新托管在Azure上的Sql Db时遇到问题。它们在本地运行良好,但在发布到Azure时似乎完全被忽略 详情: -Asp.NETMVC5.2.3 -实体框架6.1.3 -Visual Studio团队服务(联机) -Azure Web App和Azure SQL Db(在Imagine/Dreamspark订阅下) 我创建了一个不同的应用程序,它不使用CI,但在VisualStudio中使用了发布功能,它发布得很好,而且工作正常。我已经从Azure中删除了该web应用程序&
- (这对我没有任何帮助)
- (我收到一个生成错误,我的bin文件夹中没有发布定义)
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
我正在使用EF 6.1.3我也遇到了这个问题。我正在使用Visual Studio发布我的Azure应用程序服务。在做了一些研究()之后,我了解到,当您选中“更新数据库”复选框时,VS publish会转换您的web配置在发布设置中,添加一个连接字符串,该字符串引用包含_migrations表的数据库,以及“entityFramework”下的“contexts”元素。您可以通过查看“.obj\Release\insertefcodeffirstdeploy\transformed\web.config”来查看以前的发布对web.config所做的操作 因此,为了在VSTS中使用构建和发布定义时重新创建相同的操作,我在我的服务项目的Web.release.config中添加了2个XDT“insert”转换。我的看起来像这样:
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MS_TableConnectionString_DatabasePublish" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=AzureStorageEmulatorDb45;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True"
providerName="System.Data.SqlClient" xdt:Transform="Insert" />
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
<entityFramework>
<contexts xdt:Transform="Insert">
<context type="helpmeshopService.Models.helpmeshopContext, helpmeshopService">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[helpmeshopService.Models.helpmeshopContext, helpmeshopService], [helpmeshopService.Migrations.Configuration, helpmeshopService]], EntityFramework, PublicKeyToken=b77a5c561934e089">
<parameters>
<parameter value="MS_TableConnectionString_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
</entityFramework>
</configuration>
接下来,您需要转到Azure门户中的应用程序服务“应用程序设置”,添加一个名为“MS\u TableConnectionString\u DatabasePublish”的连接字符串,并将其值设置为与设置中应已存在的“MS\u TableConnectionString”相同的值。您的bin文件夹是什么样子?输出中是否有EF程序集?(将本地复制为true)我的本地计算机上的bin文件夹没有发布文件夹(这意味着我猜它也不在VSTS上,并且在该步骤中失败),因此对于查找发布配置的步骤,我将其指向obj文件夹(其中包含调试和发布文件夹)-这使得Ben概述的流程能够通过该步骤。是的,EF设置为Copy Local true。我认为您应该确保在生成定义的末尾有一个针对暂存目录的发布生成工件步骤。然后,您可以再次运行构建并导出文件树的文本版本吗-文件-目录文件