Im trying to setup a class library project with EF core 2.1 and use this class library from an .NET core api project. When I attempt to reverse engineer my schema into a dbcontext, I get an error complaining about missing EF command.
Class library csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
</ItemGroup>
</Project>
donet command
dotnet ef dbcontext scaffold "Server=.;Database=MyDb;user id=my-user;password=my-pwd;" Microsoft.EntityFrameworkCore.SqlServer -c LastMileContext -o Data
error:
No executable found matching command "dotnet-ef"
So after reading a few other threads on this, I changed my csproj file to look like this in the ItemGroup section
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
Now the EF command runs and I get my entity classes. My question is WHY do I yet have to manually add something to the csproj file? Is there not another way? Is the recommended way? Seems maybe like I missed a dotnet command step or something?
Also, looks like im not the only one who has ran into these issues https://fpnotebook.wordpress.com/2017/11/12/solution-entity-framework-core-and-net-core-class-libraries-2-0/