Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project

前端 未结 26 3020
渐次进展
渐次进展 2020-11-28 06:55

I tried to run the command \'Enable-Migrations\' in a new project and I got the message:

PM> Enable-Migrations
The term \'Enable-Migrations\' is not recog         


        
26条回答
  •  心在旅途
    2020-11-28 07:34

    This issue is occurring because we don't have Entity Framework installed. Please install Entity Framework using the below command.

    Install-Package EntityFramework -IncludePrerelease
    

    Once installed, choose the project in the package manger console default project drop down.

    Make sure at least one class in your project inherits from data context, otherwise use the below class:

    public class MyDbContext : DbContext
        {
            public MyDbContext()
            {
            }
        }
    

    If we don't do this we will get another error:

    No context type was found in the assembly

    After completing these things you can run

    enable-migrations
    

提交回复
热议问题