2

I created an ASP.NET Core Web Application (.NET Framework) project in VS2017. Then using NuGet I installed the EntityFramework 6.1.3 (I cannot use EF Core because it does not support DbGeometry and DbGeography) .

Now when trying to to run the Enable-Migrations command in Package Manager Console it throws null reference exception.

Exception calling "SetData" with "2" argument(s): .....

System.NullReferenceException: Object reference not set to an instance of an object.

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.

Here is the snapshot of the exception message

enter image description here

EDIT: I have these packages

enter image description here

Hossein Narimani Rad
  • 29,514
  • 16
  • 84
  • 113

1 Answers1

0

I got it working with the command EntityFrameworkCore\Add-Migration [your_migration_name]. There was no need for enable-migrations. If I was to try .NET framework standard add-migration [migration_name], the following warning would pop up:

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.

Tim Diekmann
  • 6,764
  • 10
  • 34
  • 58