efcore: EF Core 2.1 Preview 1 throws MissingMethodException when using Pomelo.EntityFrameworkCore.MySql
After reading that EF Core 2.1 Preview 1 became available on Nuget, I wanted to if GroupBy SQL translation would just work using a 2.0 provider. My test didn’t get far, however, and something as simple as ToListAsync
throws an exception. Provider details are at the bottom.
The article stated:
Note that although there are a few features, such as value conversions, that require an updated database provider, existing providers developed for EF Core 2.0 should be compatible with EF Core 2.1. If there is any incompatibility, that is a bug we want to hear about!
That’s why I am here.
Exception message:
System.MissingMethodException: 'Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalParameterBuilder..ctor(Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMapper)'.'
Stack trace:
at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlCommandBuilder..ctor(IDiagnosticsLogger`1 logger, IRelationalTypeMapper typeMapper)
at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlCommandBuilderFactory.CreateCore(IDiagnosticsLogger`1 logger, IRelationalTypeMapper relationalTypeMapper)
at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlCommandBuilderFactory.Create()
at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateSql(IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalExpressionPrinter.CommandBuilderPrinter.TryPrintConstant(ConstantExpression constantExpression, IndentedStringBuilder stringBuilder, Boolean removeFormatting)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitConstant(ConstantExpression constantExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.VisitLambda[T](Expression`1 lambdaExpression)
at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.PrintInternal(Expression expression, Boolean removeFormatting, Nullable`1 characterLimit, Boolean highlightNonreducibleNodes)
at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter.Print(Expression expression, Boolean removeFormatting, Nullable`1 characterLimit)
at Microsoft.EntityFrameworkCore.Internal.CoreLoggerExtensions.QueryExecutionPlanned(IDiagnosticsLogger`1 diagnostics, IExpressionPrinter expressionPrinter, Expression queryExecutorExpression)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambda[TResults]()
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateAsyncQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileAsyncQuery[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass22_0`1.<CompileAsyncQuery>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddAsyncQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQuery[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.Generic.IAsyncEnumerable<TResult>.GetEnumerator()
at System.Linq.AsyncEnumerable.<Aggregate_>d__6`3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ConsoleApp1.Program.<Main>d__0.MoveNext() in C:\Users\Adam\Desktop\MySqlCoreTesting\ConsoleApp1\Program.cs:line 42
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ConsoleApp1.Program.<Main>(String[] args)
Steps to reproduce
public class ProjectDbContext : DbContext
{
public ProjectDbContext(DbContextOptions<ProjectDbContext> options)
: base(options) { }
public DbSet<Item> Items { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Item>()
.HasKey(i => i.Id);
modelBuilder.Entity<Item>()
.Property(p => p.Label)
.HasColumnType("text");
}
}
public class Item
{
public int Id { get; set; }
public string Label { get; set; }
}
// .Net Core 2.0 Console application
class Program
{
static async Task Main(string[] args)
{
DbContextOptionsBuilder<ProjectDbContext> builder = new DbContextOptionsBuilder<ProjectDbContext>();
builder.UseMySql("Your connection string.");
using (ProjectDbContext _dbContext = new ProjectDbContext(builder.Options))
{
await _dbContext.Items.ToListAsync();
}
}
}
Further technical details
EF Core version: “Microsoft.EntityFrameworkCore.Relational” Version=“2.1.0-preview1-final” Database Provider: “Pomelo.EntityFrameworkCore.MySql” Version=“2.0.1” “MySqlConnector” Version=“0.36.0” Operating system: Windows 10 16299.248 x64 IDE: Visual Studio 2017 15.5.7
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 43 (12 by maintainers)
@pmmcmullen94 Temporary fix 1: Use EF Core 2.0 bits. Temporary fix 2: Use a pre-release build of Pomelo’s 2.1 provider, linked to in this thread.
Permanent fix: wait until Pomelo’s or Oracle’s 2.1 provider releases production quality builds. (You might be waiting a while for Oracle’s, in my opinion.)
@gsaldana The Pomelo MySQL provider is currently not working with EF Core 2.1. We are looking into potential ways that we can help with this, but we don’t have concrete plans yet.
@AdamDotNet Thanks for reporting this. It is happening because the MySQL provider is making use of EF Core internal code–I filed this issue for that: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/497
From the EF side, we will discuss in triage whether or not to revert this change to the internal code, but the long term solution is for the provider to stop using internal code.
The release version 2.1.1 of Pomelo is out now. I found it on NuGet this morning.
Oh no… I also got this after upgrading to EFCore 2.1. System.NotImplementedException: 'The ‘MySQLNumberTypeMapping’ does not support value conversions. Support for value conversions typically requires changes in the database provider.
Monitoring this: https://bugs.mysql.com/bug.php?id=89855
@OmarElMallahy Pomelo is completely separate from Oracle, and currently neither have production releases that work for EF Core 2.1. However, Pomelo recently released a 2.1 compatible release candidate. Repo comment and NuGet.
MySQL.Data.EntityFrameworkCore
is Oracle’s first party provider and there is no known time frame for it to be completed, though I opened the ticket with them that’s already been linked to in this thread.Oracle bug report: https://bugs.mysql.com/bug.php?id=89855
@roji Thanks for the great work that you’ve been doing with the Npgsql providers. I know that I can always count on you to be right on top of things. You always seem to be in lockstep with the EF team at Microsoft. I was using the 2.0.1 provider and ran into the following exception. For some reason the Y in
"p2"."actv_ind" = Y
, wasn’t quoted. When I upgraded to the 2.1.0 preview that you have, it worked fine. I just figured it was a known issue that you fixed.The query being run is.
var p = oleContext.People.Include(p2 => p2.Patron).Include(p2 => p2.PersonExt).Include(p2 => p2.PersonPrivacy).SingleOrDefault(p2 => p2.Id == id && p2.Active == "Y");
@ajcvickers Thanks for pointing this out and writing up the issue with the PomeloFoundation!
Thank you for your information. And I’m sorry. My bad. It works.
I mistook the context initialize.
optionsAction.UseMySQL(Configuration.GetConnectionString("MysqlCon"));
-> This doesn’t work on EF2.1optionsAction.UseMySql(Configuration.GetConnectionString("MysqlCon"));
-> This works on EF2.1Thanks.
Same problem here after update project to asp.net 2.1.
So I change
MySql.Data.EntityFrameworkCore
toPomelo.EntityFrameworkCore.MySql@2.1.0-rc1-final
but I lose:ForMySQLHasCharset
function for my entity configbuilder.Property(c => c.InstanceName).ForMySQLHasCharset("latin1").ForMySQLHasCollation("latin1_general_ci");
new DbContextOptionsBuilder().UseMySQL(config).Options
to lower case UseMySql atnew DbContextOptionsBuilder().UseMySql(config).Options
@DanteDiaz only temporary in that when the production release is available, one should stop using the pre-release build. I’m glad the pre-release build is working for you in the meantime!
@sam-wheat - PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#497