asp.net - 似乎无法使启用迁移工作成功安装但未添加
问题描述
一般来说,我对实体框架和 ASP.NET 很熟悉。我已经安装了 EF,当我编写启用迁移时,我得到以下行在程序集“Demogorgon”中找不到上下文类型。
我试过 1. 安装和卸载 EF 2. 确保我选择了正确的项目作为默认项目(很容易在下拉列表中只有一个) 3. 用于安装 EF 控制台或管理 nugets 4. 我正在阅读在这里和其他地方的答案,但由于我对此很陌生,所以我不知道如何进行
Attempting to gather dependency information for package 'EntityFramework.6.4.4' with respect to project 'Demogorgon', targeting '.NETFramework,Version=v4.7.2'
Gathering dependency information took 1.14 sec
Attempting to resolve dependencies for package 'EntityFramework.6.4.4' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'EntityFramework.6.4.4'
Resolved actions to install package 'EntityFramework.6.4.4'
Retrieving package 'EntityFramework 6.4.4' from 'nuget.org'.
Adding package 'EntityFramework.6.4.4' to folder 'C:\Users\novot\source\repos\Demogorgon\packages'
Added package 'EntityFramework.6.4.4' to folder 'C:\Users\novot\source\repos\Demogorgon\packages'
Added package 'EntityFramework.6.4.4' to 'packages.config'
**Successfully installed 'EntityFramework 6.4.4' to Demogorgon**
Executing nuget actions took 1.49 sec
Time Elapsed: 00:00:02.7731151
PM> Enable-Migrations
No context type was found in the assembly 'Demogorgon'.
PM> enable-migrations
No context type was found in the assembly 'Demogorgon'.
PM>
解决方案
确保在包管理器控制台(默认项目下拉选项)中选择了正确的项目(DBContext 类所在的项目),然后重试
推荐阅读
- python - 如何在可以通过关键字访问的列表中创建列表
- python - 为什么我得到对象不可调用?
- javascript - 单击时如何为字符串的一部分创建边框:Reactjs
- scala - 访问案例类参数参与者
- java - 为什么在这个实例化类的例子中没有“new”关键字?
- python - 如何使“在线”搜索更精确?
- javascript - 节点 - 不能在同一文件夹中要求('./index.js')
- react-native - 收到警告:“componentWillUpdate 已弃用,将在下一个主要版本中删除”使用反应导航的 navigationOptions
- xamarin - 谷歌播放的 Xamarin 优化
- javascript - 将数组中的一串数字转换为纯整数数组