作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
使用 VS Community 2017。我尝试创建初始迁移,并显示错误消息:
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.
...我的 dbcontext 中的代码:
protected override void OnModelCreating(DbModelBuilder mb)
{
base.OnModelCreating(mb);
mb.Entity<Stuff>().ToTable("Stuff");
}
public DbSet<Stuff> Stuff{ get; set; }
最佳答案
在包管理器控制台中,选择定义了 DbContext
的项目并运行命令 add-migration initial
。例如:public class SomeContext : DbContext
关于c# - 迁移 : No DbContext was found in assembly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46679202/
我是一名优秀的程序员,十分优秀!