EF 7的Add-Migration命令的-Context参数的正确语法是什么? [英] What is the correct syntax to the -Context parameter of EF 7's Add-Migration command?

查看:559
本文介绍了EF 7的Add-Migration命令的-Context参数的正确语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用EntityFramework 7的最新预发行版本(v7.0.0-rc1-final),我尝试通过Package使用 Add-Migration PowerShell命令Visual Studio中的管理器控制台;我试图将迁移添加到我的DAL中。

Using the latest pre-release version of EntityFramework 7 (v7.0.0-rc1-final), I have tried to use the Add-Migration PowerShell command through the Package Manager Console in Visual Studio; I have tried to add migrations to my DAL.

文件夹结构类似于:

-Project
  -DAL
    -Context.cs

我尝试了以下命令的变体:

I have tried variations of the following command:

Add-Migration Initial -OutputDir DAL\Migrations -Context ContextClassName

包括但不限于:

添加迁移初始-OutputDir DAL迁移-Context Project.Namespace.DAL.ContextClassName

添加迁移初始-OutputDir DAL \迁移-Context DAL\Context.cs

无济于事...

工具包的安装方式如下:

The package for the tools is installed like so:

Install-Package Microsoft.EntityFrameworkCore.Tools -Pre

文档没什么用和获取帮助添加迁移-示例-完整-详细等。没有给您任何与 -Context 参数的预期格式有关的信息。

The docs are less than helpful and Get-Help Add-Migration -Examples and -Full, -Detailed etc. give you nothing relating to the expected format of the -Context parameter.

什么是

推荐答案

您使用的是错误的EF7软件包! 根据公告,不再有Entity Framework 7,而只有EntityFrameworkCore。

You're using the wrong EF7 package! As per the announcement, there's no longer an Entity Framework 7 but only EntityFrameworkCore.

根据您的链接文档,并特别遵循完整DotNet 您需要引用 Microsoft.EntityFrameworkCore。* 而不是EntityFramework。*(对于EF7)

As per your linked documentation and specifically following the documentation section for Full DotNet You need to reference Microsoft.EntityFrameworkCore.* and not EntityFramework.* (for EF7)

遵循上一页的说明并发出:

Following the instructions of above page and issuing:

Add-Migration -OutputDir DAL\迁移-Context ContextClassName

我对迁移进行排序没有问题。

I have no issue getting the migration sorted.

这篇关于EF 7的Add-Migration命令的-Context参数的正确语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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