EF Core 8 Method not found: 'Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping – C#

by
Liam Thompson
.net-8.0 abstractclass asp.net-core-8 ef-core-8.0

Quick Fix: Depending on Pomelo.EntityFrameworkCore.MySql library version being used, make sure your Microsoft.EntityFrameworkCore.Relational library is of compatible version.

The Problem:

A developer has encountered an exception while updating to .NET 8 and EF Core 8 during database migration. The error message indicates that the method ‘Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping.Clone’ is not found. The issue appears when using Pomelo.EntityFrameworkCore.MySql for MySQL database connectivity. The developer has provided the necessary code snippets, including the DbContext, entity classes, and repositories, to demonstrate the context of the problem.

The Solutions:

Solution 1: Update package versions

To resolve the issue, consider updating the following packages in your project file:

  • Pomelo.EntityFrameworkCore.MySql to version 8.0.0-preview8 or later.
  • Microsoft.EntityFrameworkCore.Relational to version 8.0.0-preview8 or later.
  • Microsoft.EntityFrameworkCore.Tools to version 8.0.0-preview8 or later.
<ItemGroup>
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-preview8" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0-preview8" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-preview8">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
</ItemGroup>

Q&A

What is the problem?

The problem is that Pomelo.EntityFrameworkCore.MySql uses Microsoft.EntityFrameworkCore.Relational 8.0.0-rc.1.23419.6, which is larger than 8.0.0.

What is the solution?

Change the version of Microsoft.EntityFrameworkCore.Relational to 8.0.0-rc.1.23419.6 to solve the problem.

Video Explanation:

The following video, titled "Fix: MissingMethodException: Method not Found ASP.NET CORE ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

In this video, I am going to fix this issue in ASP.NET CORE: MissingMethodException: Method not Found: System.