How To Add EF Core To VS2017 projects

EF Core issues in VS2017

Claudiu Tomescu

2 minute read

Visual Studio 2017 has been released a few weeks ago, so I’m tinkering with the .NET Core tooling in VS2017 as I’m following Julie’s Pluralsight course on EF Core. In doing so, I’ve come across a few things, which I though I would write a blog about, so that other may benefit from.

EF Core comes with command line tools that you can use outside Visual Studio. This is an alternative to the PowerShell commands you can use from VS’s Package Manager’s Console.

My solution consists of 2 .NET Core (.NET Standard Library) projects: SamuraiAppCore.Domain contains the domain classes, which are essentially plain C# classes, and SamuraiAppCode.Data which contains all the EF related code: context class, EF fluent configurations, etc.

I’ve already added the Microsoft.EntityFrameworkCore.SqlServer Nuget package to the SamuraiAppCore.Data project, and now in order to use the EF Core migrations, I need to add the Microsoft.EntityFrameworkCore.Tools.DotNet Nuget package. However, when I try to add it I’m getting an error in Visual Studio 2017:

Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0' has a package type 'DotnetCliTools' that is not supported by project 'SamuraiAppCore.Data'

EFCore NuGet Error Message

I’ve tried different options, by changing the project the project type, or even the target .NET Standard version, but I wasn’t able to do get around this issue. The only way to solve it was to manually edit the SamuraiAppCore.Data.csproj file and add the required references:

.csproj EF Tools References

Now, if we open a terminal in the SamuraiAppCore.Data project folder and type dotnet ef command we get proper access to EF Core tooling:

EFCore CLI working properly

I recommend you see Julie’s Pluralsight course on how to use EF Core migrations.

comments powered by Disqus
comments powered by Disqus