[英]EF6 Enable-Migrations not working in ASP.NET Core (.NET Framework)
I created an ASP.NET Core Web Application (.NET Framework) project in VS2017. 我在VS2017中创建了一个ASP.NET Core Web应用程序(.NET Framework)项目。 Then using NuGet I installed the EntityFramework 6.1.3 (I cannot use EF Core because it does not support DbGeometry
and DbGeography
) . 然后使用NuGet安装了EntityFramework 6.1.3 (我不能使用EF Core,因为它不支持DbGeometry
和DbGeography
)。
Now when trying to to run the Enable-Migrations
command in Package Manager Console it throws null reference exception. 现在,当尝试在Package Manager控制台中运行Enable-Migrations
命令时,它将引发空引用异常。
Exception calling "SetData" with "2" argument(s): ..... 带有“ 2”自变量的调用“ SetData”的异常:..
System.NullReferenceException: Object reference not set to an instance of an object. System.NullReferenceException:对象引用未设置为对象的实例。
There is only one project in my solution and is set in the Default project part of the Package Manager Console. 我的解决方案中只有一个项目,并且在“程序包管理器控制台”的“默认项目”部分中进行了设置。 I have read this and this but non of them work in my case. 我已阅读这个和这个 ,但他们非在我的情况下工作。 Also there is not project.json
file in my solution, it seems some of these answer are out of date. 我的解决方案中也没有project.json
文件,似乎其中一些答案已经过时了。
Here is the snapshot of the exception message 这是异常消息的快照
EDIT: I have these packages 编辑:我有这些包
I got it working with the command EntityFrameworkCore\\Add-Migration [your_migration_name]
. 我通过命令EntityFrameworkCore\\Add-Migration [your_migration_name]
。 There was no need for enable-migrations
. 无需进行enable-migrations
。 If I was to try .NET framework standard add-migration [migration_name]
, the following warning would pop up: 如果我尝试使用.NET Framework标准add-migration [migration_name]
,则会弹出以下警告:
Both Entity Framework 6.x and Entity Framework Core commands are installed.
The Entity Framework 6 version is executing. You can fully qualify the command to select which one to execute, 'EntityFramework\Add-Migration' for EF6.x and 'EntityFrameworkCore\Add-Migration' for EF Core.'
Followed by the same exception you pasted above. 其次是您上面粘贴的相同异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.