Migration: No DbContext was found in assembly

雨燕双飞 提交于 2019-12-08 20:38:21

问题


Using VS Community 2017. I have tried to create initial migration with error message saying:

Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6. No DbContext was found in assembly 'Test_Project'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

... code in my dbcontext:

protected override void OnModelCreating(DbModelBuilder mb)
{
    base.OnModelCreating(mb);

    mb.Entity<Stuff>().ToTable("Stuff");

}

public DbSet<Stuff> Stuff{ get; set; }

回答1:


In the Package Manager Console select the project where the DbContext is defined and run the command add-migration initial For Ex:public class SomeContext : DbContext



来源:https://stackoverflow.com/questions/46679202/migration-no-dbcontext-was-found-in-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!