Enable-Migrations “Object reference not set to an instance of an object”

百般思念 提交于 2019-12-05 05:13:38
Ondras

I have resolved the same exception issue by specifying -StartUpProjectName parameter of Enable-Migrations command to my .NET framework dll with the db context. The issue might be with the weird startup project - problem in .IsWebProject() (asp.core in my case). See more detail answer on Enable-Migrations Exception calling "SetData" with "2" argument(s).

Mohammad Yoosefiyan

If you are using visual studio 2019, when you want to add a new class library you face to kind of class library:

  1. Class Library (.NET Standard)

  2. Class Library (.NET Framework)

Well, I used to pick number1, but now I know I have made mistake.

The solution is to Pick number2.

Instead of Enable-Migrations Do this EntityFrameworkCore\Enable-Migrations

Use EntityFrameworkCore\ before any command.

PS: Using VisualStudio 2019

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!