简体   繁体   English

EF Core 在迁移期间删除 EF 依赖项

[英]EF Core removes EF dependencies during migration

I've been trying to set up EFCore with .NET6.我一直在尝试使用 .NET6 设置 EFCore。 When all my Models/Entities are inside a folder, the Initial Migration I ran removes all the dependencies(some) from the project and results in a failed build.当我所有的模型/实体都在一个文件夹中时,我运行的初始迁移会从项目中删除所有依赖项(一些)并导致构建失败。 But when I initially store my model in the root directory and run the same command it works.但是,当我最初将模型存储在根目录中并运行相同的命令时,它可以工作。

This is the folder structure which causes the issue这是导致问题的文件夹结构

这是导致问题的文件夹结构

实际问题

Update更新

The last time I tried migrations worked if I placed the models and entities at the project's root, but now, even if I do, the same error happens.如果我将模型和实体放在项目的根目录中,我最后一次尝试迁移工作,但现在,即使我这样做,也会发生同样的错误。 Please help me with this error.请帮我解决这个错误。 Thanks in advance.提前致谢。

Apparently, Visual Studio did not save the changes to the .csproj file on disk when I installed all the NuGet packages which resulted in the build failed error.显然,当我安装所有导致构建失败错误的 NuGet 包时,Visual Studio 没有将更改保存到磁盘上的 .csproj 文件。 This issue will not happen when we use visual studio to build the project because it will persist the changes to the disk when we do that but I used the CLI to build and run the migrations which resulted in this error.当我们使用 Visual Studio 构建项目时,不会发生此问题,因为它会在我们这样做时将更改保存到磁盘,但我使用 CLI 构建和运行导致此错误的迁移。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM