使用Azure DevOps管道中的.NET Framework从Entity Framework更新数据库

问题描述

将Entity Framework更新至版本6.4.4后,migrate.exeef6.exe取代。这对我在Azure DevOps中的发布管道进行了重大更改。我试图从最初的工作中更新迁移命令

$(System.DefaultWorkingDirectory)/_IdentityServer-CI-Build/drop/migration/migrate.exe Identity Identity.Migrations.AspNetIdentity.Configuration /connectionString=$(connectionstring) /connectionProviderName="System.Data.sqlClient"

到当前版本

$(System.DefaultWorkingDirectory)/_IdentityServer-CI-Build/drop/migration/ef6.exe database update --verbose --assembly Identity.dll --connection-provider "System.Data.sqlClient" --connection-string '$(connectionstring)'

$(Build.sourcesDirectory)\packages\EntityFramework.6.4.4\tools\net45\any\ef6.exe的副本上运行。

不幸的是我遇到了错误

System.Data.Entity.Tools.CommandException: Your target project 'Identity' doesn't reference EntityFramework. This package is required for the Entity Framework Core Tools to work. Ensure your target project is correct,install the package,and try again. ---> System.IO.FileNotFoundException: Could not load file or assembly 'EntityFramework' or one of its dependencies. The system cannot find the file specified.

根据错误,在我看来该工具不适合.NET Framework项目。由于实际上没有文档可以在.NET Framwork项目上使用此工具,因此我检查了源代码以至少获取参数,但是我不知道该如何处理此错误或使用哪种不同的方法来执行此操作。从管道更新。

解决方法

使用ef6.exe的6.4.4版本对以下内容执行迁移:

数据库更新-详细-组件Identity.dll-迁移配置Identity.ClientConfiguration.Configuration-项目目录'D:\ drop \ Identity'-连接字符串'$(连接字符串)'-连接提供者“ System.Data.SqlClient”