首页 > 解决方案 > 似乎无法使启用迁移工作成功安装但未添加

问题描述

一般来说,我对实体框架和 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> 

标签: asp.net

解决方案


确保在包管理器控制台(默认项目下拉选项)中选择了正确的项目(DBContext 类所在的项目),然后重试


推荐阅读