生成初始迁移时出错:类型或名称空间名称“迁移”不存在

问题描述 投票:0回答:1

我有2个Visual Studio项目; .net核心Web API 3.1项目(用于ef迁移的启动)和包含dbcontext的类库。当我打开Powershell窗口时,导航到我的类库的文件夹,然后使用快照文件执行dotnet ef migrations add Initial --startup-project [path to csproj-file for the web API project]迁移文件夹,并创建了初始迁移文件。

但是当我在Visual Studio中打开迁移文件时,出现了几个编译错误,其中一个抱怨The type or namespace 'Migrations' does not exist in the namespace 'Microsoft.EntityFrameworkCore'...,我还可以看到自动生成的迁移文件包含指向Microsoft.EntityFrameworkCore.Migrations的using语句,该语句被标记为不必要和msdn的文档清楚地包含了编译器引用的基础Migration类和MigrationBuilder类。

我尝试在Nuget.org上同时寻找Microsoft.EntityFrameworkCore.MigrationsMicrosoft.EntityFrameworkCore.All,但都不存在。我在这里错过明显的东西吗?为什么自动生成的迁移文件无法编译?

ef-migrations
1个回答
0
投票

显然,我对Migration类的msdn文档不够仔细。它位于Microsoft.EntityFrameworkCore.Relations程序集中,在安装了Nuget软件包之后,该项目现在可以正确编译。

© www.soinside.com 2019 - 2024. All rights reserved.