实体框架核心1.0.1添加迁移 [英] Entity Framework Core 1.0.1 add-migration

查看:84
本文介绍了实体框架核心1.0.1添加迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于EF Core迁移到 Microsoft.EntityFrameworkCore。* (而不是 EntityFramework。* ),因此推荐的添加数据库迁移的命令行从软件包管理器回到 add-migration

Since EF Core migrated to Microsoft.EntityFrameworkCore.* (instead of EntityFramework.*), it seems that the recommended command line to add db migrations is back to add-migration from package manager.

ef core添加迁移文档

但是似乎不再有用于命令的软件包了, 1.0.1版的软件包安装不添加任何命令。

However it seems there isn't a package anymore for commands and that the package installation of v 1.0.1 doesn't add any command.

运行添加迁移时收到的错误消息是

The error message I'm getting when running Add-Migration is


无法执行此命令,因为未在启动项目项目名称中安装EntityFramework.Commands。

Cannot execute this command because EntityFramework.Commands is not installed in the startup project 'project name'.

我错过了什么吗?有没有新的方法来添加命令?谢谢您的帮助!

Did I miss something? Is there a new way to add the commands or so? Thanks for your help!

推荐答案

为了使用程序包管理器控制台命令(例如 Add-Migration) )在.NET Core项目上,您的 project.json 将需要看起来像这样。

In order to use the Package Manager Console commands (e.g. Add-Migration) on .NET Core projects, your project.json will need to look something like this.

{
    "dependencies": {
        "Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",
        "Microsoft.EntityFrameworkCore.Tools": {
            "version": "1.0.0-preview2-final",
            "type": "build"
        }
    },
    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
    }
}

依赖项下的 Microsoft.EntityFrameworkCore.Tools c $ c>确保PowerShell命令得到注册。 type: build 确保它们不会随您的应用程序一起发布。 依赖项下的 Microsoft.EntityFrameworkCore.Tools 确保 dotnet ef 命令被注册(由PowerShell命令调用)。

The Microsoft.EntityFrameworkCore.Tools under dependencies ensures the PowerShell commands get registered. It's "type": "build" ensures they don't get published with your application. The Microsoft.EntityFrameworkCore.Tools under dependencies ensures the dotnet ef command gets registered (which is called by the PowerShell commands).

这篇关于实体框架核心1.0.1添加迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆