I use Visual Studio for Mac, created a .net core web api project. The csproj file is like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.9-dmr" />
<PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.9-dmr" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
When I execute "dotnet ef dbcontext scaffold" to scaffold from MySQL with the following command:
dotnet ef dbcontext scaffold "server=[server];port=3306;user=[user];password=[password];database=[dbname]" MySql.Data.EntityFrameworkCore -o Models -c [contextname] -f -v
The command returned error like this:
Could not load type 'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute' from assembly 'Microsoft.EntityFrameworkCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
I checked the package Microsoft.EntityFrameworkCore. It is true that no Infrastructure namespace in that package. But Searched online, I find others can successfully scaffold with such settings. Is there anything I did wrong? How can I scaffold correctly?
Thank you all.
you should add Microsoft.EntityFrameworkCore.SqlServer
package from NuGet packages, this worked for me. hope, this works for you too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With