我开始使用 EF Core 2.0,我有一个针对 .NET 4.6.1 的控制台应用程序我有一个非常简单的模型类,并且这个上下文:
public class ContextCore : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["efCoreCon"].ConnectionString);
}
public DbSet<ModelC> Models { get; set; }
}
这是连接字符串:
<add name="efCoreCon" connectionString="server=PC-MSHWF\SQLEXPRESS;database=efCoreDB;integrated security=true;" />
我注意到官方文档Enable-Migrations
中没有in ef core的命令
所以我跑Add-migration firstMigration
了,但我得到了这个错误:
在程序集“NewConsole”中找不到迁移配置类型。(在 Visual Studio 中,您可以使用包管理器控制台中的 Enable-Migrations 命令添加迁移配置)。
当我尝试 Enable-Migrations 时,出现此错误:
在程序集“NewConsole”中找不到上下文类型。