gpt4 book ai didi

c# - 迁移 : No DbContext was found in assembly

转载 作者:太空狗 更新时间:2023-10-29 21:16:18 29 4
gpt4 key购买 nike

使用 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com