Enable-Migrations gives Exception calling "SetData" with "2" argument(s) error

entity-framework entity-framework-6 visual-studio-2017


I have used Entity Framework migrations numerous times before, but I am unable to enable migrations in a new demo project I just created. I have tried the different options recommended on SO Posts but nothing seems to work. Here is how the project was created (essentially following Julia Lerman's book example):

  1. Created a blank Visual Studio solution
  2. Added class library project for Models, DataAccess (.NET standard)
  3. Added DbContext in DataAccess project
  4. Added a console application project to the solution
  5. Used NuGet to install EntityFramework 6 to the DataAccess and ConsoleApplication projects

The project runs fine and creates the database in the SQLEXPRESS server on my desktop. There was no connection string anywhere in the application. There is also no app.config file in the DataAccess project. The only app.config is in the console application project.

I even added a connection string to the console application's app.config and tried the different options with enable-migrations. But nothing seems to work.

Using Visual Studio 2017 15.5.4 Community Edition

Visual Studio screenshot

1/29/2018 12:56:36 AM

Popular Answer

Reading this SO post suggested that maybe some project types may not be compatible with EF 6 migrations. So, instead of using a class library project type of ".NET standard" for the DataAccess project, I tried using the ".NET framework" project type for the DataAccess class library project (where the DbContext is defined). Migrations worked fine as before.

1/29/2018 1:21:51 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow