简体   繁体   English

如何在实体框架中进行迁移?

[英]How do I make migrations in Entity Framework?

My research keeps telling me to use the Migrate.exe , which has not shown up in my project, and it cannot be downloaded anywhere.我的研究一直告诉我使用Migrate.exe ,它没有出现在我的项目中,并且无法在任何地方下载。 I am also using VS Code and not Visual Studio, which seems to make it impossible to use the Package Manager Console.我也在使用 VS Code 而不是 Visual Studio,这似乎使得无法使用 Package 管理器控制台。

And I am using Entity Framework - not Entity Framework Core - so I do not have all the options of EFC.而且我使用的是实体框架——而不是实体框架核心——所以我没有 EFC 的所有选项。

Currently I am trying to set Entity Framework up in Unity, the game engine.目前我正在尝试在游戏引擎 Unity 中设置实体框架。 It was possible to set up a temporary project with Entity Framework v6.2.0 and run dotnet pack to get the EntityFramework.dll but it does not create the Migrate.exe .可以使用 Entity Framework v6.2.0 设置一个临时项目并运行dotnet pack以获取EntityFramework.dll但它不会创建Migrate.exe And it seems to be the only option for creating migrations.它似乎是创建迁移的唯一选择。

Do any of you know how to get the Migrate.exe file or another way to add migrations?你们中有人知道如何获取Migrate.exe文件或其他方式来添加迁移吗?

When you install Entity Framework using NuGet migrate.exe will be inside the tools folder of the downloaded package.当您使用 NuGet 安装实体框架时,migrate.exe 将位于下载的 package 的工具文件夹中。 In \packages\EntityFramework.\tools在 \packages\EntityFramework.\tools

Source is microsoft来源是微软

have you tried this?你试过这个吗?

Apparently there is a difference in installing and adding, not that they mention that when you look at the package on nuget.org.显然安装和添加是有区别的,并不是说当您查看 nuget.org 上的 package 时,他们会提到这一点。

So rather than running dotnet add package EntityFramework --version 6.2.0 I needed to download the latest nuget.exe from nuget.org and create a packages.config file in the root folder.因此,我需要从 Z0558440846982BFE7FF23B159C377F9B 文件夹中下载最新的 nuget.exe,而不是运行dotnet add package EntityFramework --version 6.2.0并创建 packages.org 文件。

I then ran nuget.exe install packages.config -OutputDirectory packages which installed all the files I needed.然后我运行nuget.exe install packages.config -OutputDirectory packages安装了我需要的所有文件。

packages.config:包.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.2.0" targetFramework="net40" />
</packages>

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

相关问题 如何为IdentityServer4实体框架核心迁移指定架构? - How do I specify a schema for IdentityServer4 Entity Framework Core Migrations? 如何指示实体框架基于当前数据库选择迁移? - How do I instruct entity framework to choose migrations based on the current database? 如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移 - How do I run ASP.NET Core Entity Framework migrations from Visual Studio Team Services 实体框架6:如何使用代码优先迁移和FTP部署重置数据库 - Entity Framework 6: How do I reset a database using code first migrations and an FTP deploy 如何获得“实体框架代码优先”迁移来查看我的模型? - How do I get Entity Framework Code First Migrations to see my models? 如何使用代码迁移配置禁用延迟加载,实体框架4.1 - How Do I Disable Lazy Loading, Entity Framework 4.1 using Code Migrations Configuration 无法使其工作实体框架迁移 - can't make it work entity framework migrations 实体框架核心运行缓慢-如何使其更快? - Entity Framework Core is slow - how do I make it faster? 如何在 Entity Framework Core 3.1 中对自定义对象执行原始 SQL 查询,而无需迁移想要创建表? - How do I execute a raw SQL query to a custom object in Entity Framework Core 3.1, without migrations wanting to create a table? 我应该提交Entity Framework迁移吗? - Should i commit Entity Framework migrations?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM