I have 2 projects in my solution, I have a project with Entity Framework Core installed:
And in the other ASP.NET Web API project I have these packages:
Set the project with entities as the Startup project and run the scaffolding command. it worked for me. Don't forget to set the revert the startup project after.
I got this error because Visual Studio defaulted to using entity framework core rather than old-school entityframework for .NET Framework: entity framework 6. This was my solution:
EntityFramework\Update-Database
Or reference the version explicitly:
EntityFramework6\Update-Database
Also worth checking the right project is selected in the Package Manager Console. That likes to sneak back to other projects half the time!
There is absolutely NO reason to install Microsoft.EntityFrameworkCore.Design to your API project while having a separate Data project.
When using add-migration, just add a parameter to set the -StartUpProject to your Data proj (by default I presume your startup project is the API proj).
Example add-migration command below:
add-migration {migration_name} -StartUpProject {your_data_proj_name} -project {your_data_proj_name} -v
Example update-database command below:
add-migration {migration_name} -StartUpProject {your_data_proj_name} -project {your_data_proj_name} -v
I hope this help you guys
PS: more info about the add-migration params can be found here
I found the solution here: http://obscureproblemsandgotchas.com/development/c/dotnet-core-ef-migration-not-working/
In short, edit your csproj file, and add to your PropertyGroup
section following entry:
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
Try to set your web project again as startup project and this warning should go. (Right click on web project > Set as startUp project)
In order for the migration tool to work, I had to add the Microsoft.VisualStudio.Web.CodeGeneration.Design
NuGet package as well.