I try to use EF with MySQL in my project. And I add:
MySql.Data.EntityFrameworkCore
MySql.Data.EntityFrameworkCore.Design
into my project.json
but the tools section of project.json
is empty. When I run:
Scaffold-DbContext "myconnectionstr" MySql.Data.EntityFrameworkCore -OutputDir Models -StartupProject "myproject"
The console shows me an error:
Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly MySql.Data.EntityFrameworkCore
MySql is the most popular Entity Framework Core provider for MySQL compatible databases. It supports EF Core 3.1 (and lower) and uses MySqlConnector for high-performance database server communication. The following versions of MySqlConnector, EF Core, . NET Standard and .
You can't put an EF6 context in an ASP.NET Core project because . NET Core projects don't support all of the functionality that EF6 commands such as Enable-Migrations require.
It seems that "official" provider MySql.Data.EntityFrameworkCore 7.0.7-m61
still unsupports scaffolding. However, it works fine with Pomelo.EntityFrameworkCore.MySql
free community provider:
dotnet ef dbcontext scaffold "Host=localhost;Port=3306;Database=foodb;Username=root;Password=mysql" ^
Pomelo.EntityFrameworkCore.MySql ^
--force ^
--context "FooContext" ^
--output-dir "Entities" ^
--verbose
Our csproj (Visual Studio 2017):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="1.1.2-preview-10036" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2-preview-10036" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
</Project>
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