Can't add migrations to database after migrating .net core

.net-core entity-framework-core


I'm working on a project that was created using a version of dotnet core using a project.json file. I was able to add database migrations and create a database using dotnet ef cli commands in VS Code (add migrations, update, etc.).

However, I've recently migrated the project using the dotnet migrate command, so now my project has a .csproj file. I need to add more database migrations, but when I run the cli commands, I get an error stating the project.json file could not be found.

I've looked at documentation online (and searched the web) and I can't find anything telling me what I might have missed. FWIW, here are the possible relevant packages in my .csproj file:

  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final" />
2/17/2017 4:40:16 PM

Accepted Answer

New versions of the tooling were released for the new .csproj way of doing things. You'll need to change your version of Microsoft.EntityFrameworkCore.Tools.DotNet from 1.1.0-preview4-final to 1.0.0-msbuild3-final.

You can see the different latest versions here on Nuget.

2/17/2017 6:22:11 PM

Popular Answer

If you don't need the "dotnet ef" tools specifically you can also use the VS Powershell integrated version (Should you need the dotnet ef tools maybe steamrolla's post below can help you):

I use the following package references:

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />

With these references set, it is possible to use the EF-Tools (Add-Migration, Update-Database, ...) from the Package Manager Console.

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