简体   繁体   English

Entity Framework 6 .net Framework 迁移/包管理控制台 - 如何在 Azure Pipeline 中运行这些?

[英]Entity Framework 6 .net Framework Migrations / Package Management Console - How Do You Run These In An Azure Pipeline?

I am setting up an Azure Release Pipeline and I need to execute any pending DB Migrations as part of the release.我正在设置 Azure 发布管道,作为发布的一部分,我需要执行任何挂起的数据库迁移。

I have been scouring the internet for over an hour and everything I can find is about dotnet Core, while the database is EF6 on .Net Framework, not dotnet Core (I've done this several times before for Core).我已经在互联网上搜索了一个多小时,我能找到的所有内容都是关于 dotnet Core,而数据库是 .Net Framework 上的 EF6,而不是 dotnet Core(我之前为 Core 做过几次)。

The problem, as I see it, is that EF6 works using Visual Studio's built in Package Manager Console - This just doesn't exist in an Azure Pipeline;在我看来,问题在于 EF6 使用 Visual Studio 的内置包管理器控制台工作——这在 Azure Pipeline 中不存在; It's a Visual Studio weirdness.这是 Visual Studio 的怪异之处。

There seems to be several ways I can skin this cat, in my head, but I can't figure out how to start with either of them within the context of the pipeline...在我的脑海里,似乎有几种方法可以给这只猫剥皮,但我无法弄清楚如何在管道的上下文中从它们中的任何一个开始......

OPTION 1: Run the Migrations on the Pipeline - but... how?选项 1:在管道上运行迁移 - 但是......如何?

OPTION 2: SQL Scripts - Requires running the Package Manager to generate them so they can be run (if I could do that on the pipeline then I'd just run it anyway so these would have to be created locally and committed with the code which is somewhat backward as a solution IMO)选项 2:SQL 脚本 - 需要运行包管理器来生成它们,以便它们可以运行(如果我可以在管道上这样做,那么无论如何我都会运行它,所以这些必须在本地创建并与代码一起提交)作为解决方案 IMO 有点落后)

OPTION 3: Write a console app - Do I really have to do this??选项 3:编写控制台应用程序 - 我真的必须这样做吗?

You can try Entity Framework Migration Extensions .您可以尝试Entity Framework Migration Extensions

This task allows a Build / Release to provide database connection parameters and execute an Entity Framework 6 migration against the database.此任务允许构建/发布提供数据库连接参数并针对数据库执行 Entity Framework 6 迁移。

  1. Build your project to an output folder and include the migrate.exe executable that comes with Entity Framework 6.将项目构建到输出文件夹并包含 Entity Framework 6 附带的 migrate.exe 可执行文件。
  2. Create an automated build that packages up your files and makes them accessible during a Release.创建一个自动构建来打包您的文件并使其在发布期间可以访问。
  3. Create a Release definition for the relevant Build为相关构建创建发布定义
  4. Add an EF6 Migration task.添加 EF6 迁移任务。 Once that task is added to an environment within the release, you'll need to enter the appropriate parameters to configure it.将该任务添加到发行版中的环境后,您需要输入适当的参数来配置它。 All file path parameters should be within the file system for the build, none of them are for TFS source control paths.所有文件路径参数都应该在构建的文件系统内,它们都不是用于 TFS 源控制路径。

You can also check this article .您也可以查看这篇文章

The answer here is to use the ef6.exe command line tool and make sure it gets shipped with your build.这里的答案是使用 ef6.exe 命令行工具并确保它随您的构建一起提供。

This could be useful to anyone here until Microsoft update the non-existent docs: http://github.com/dotnet/EntityFramework.Docs/issues/1740 - This contains a table with a kind of translation matrix between the two.在 Microsoft 更新不存在的文档之前,这对这里的任何人都可能有用: http : //github.com/dotnet/EntityFramework.Docs/issues/1740 - 这包含一个表,其中包含一种两者之间的转换矩阵。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移 - How do I run ASP.NET Core Entity Framework migrations from Visual Studio Team Services 实体框架迁移 Azure DevOps 发布管道 - Entity Framework Migration Azure DevOps Release Pipeline 使用实体框架迁移的 Azure Dev Ops 发布问题 - Azure Dev Ops Release Issue Using Entity Framework Migrations 在 Azure DevOps 中通过 CI 和 CD 迁移 Entity Framework Core - Entity Framework Core migrations through CI and CD in Azure DevOps 在 Azure Pipeline 和 Linux 上构建 .Net Framework - Build .Net Framework on Azure Pipeline and Linux 使用 Azure DevOps CICD 管道将旧版 .net 框架控制台应用程序部署到本地服务器 - Deploy legacy .net framework console application to on prem server using Azure DevOps CICD pipeline 如何修复:在 Azure Devops 构建管道实体框架不生成 SQL 脚本 - How to fix: In Azure Devops build pipeline Entity Framework doesn't generate SQL script 如何在没有浏览器身份验证的情况下在 Azure DevOps 构建管道中使用无服务器框架? - How do I use the Serverless Framework in an Azure DevOps Build Pipeline without Browser Authentication? 您如何延迟和安排一个阶段以仅在 Azure Devops yaml 管道中运行最新版本? - How do you delay and schedule a stage to only run the latest build in an Azure Devops yaml pipeline? 如何在 Azure 管道中包含二进制框架? - How can I include a binary framework in an Azure Pipeline?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM