Errors using Pomelo MySQL EF provider with ASP.NET Core 2.0 Preview

7

I am using Pomelo 1.1.2 on ASP.NET Core 2.0 Preview, along with EF 2.0 Preview. With their demo code, I get the following exception every time I call "UseMySql":

System.TypeLoadException occurred
  HResult=0x80131522
  Message=Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Internal.MySqlOptionsExtension' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
   at CoreTest1.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\DEV\Experiments\CoreTest1\CoreTest1\Startup.cs:line 27
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass0_0`1.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass5_0`1.<AddCoreServices>b__0(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactoryService(FactoryService factoryService, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass17_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at CoreTest1.Controllers.HomeController.Index() in C:\DEV\Experiments\CoreTest1\CoreTest1\Controllers\HomeController.cs:line 18
   at Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__18.MoveNext()

Wondering if this is just because of the 2.0 preview libraries? Any ideas? I tried to look through their source code on Git to see if I could spot anything immediately wrong, but could not.

mysql
asp.net-core
entity-framework-core
asp.net-core-2.0
pomelo-entityframeworkcore-mysql
asked on Stack Overflow May 15, 2017 by Ron Penton • edited Sep 23, 2020 by lauxjpn

3 Answers

9

Let's look at EF Core 2.0 Preview 1 announcement:

If you are using a third party database provider, then check to see if they have released an update that depends on 2.0.0-preview1-final. If they have, then just upgrade to the new version. If not, then you will not be able to upgrade since version 2.0 contains several breaking changes and 1.* providers are not expected to work with it.

That means Pomelo isn't expected to support EF Core 2.0 until a comparatible release is produced.

answered on Stack Overflow May 15, 2017 by Ilya Chumakov
2

Recently, faced the same error during my project update to .NET Core 2.0. At this moment, solution is described in https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql Basically, update package to the prereleased version 2.0.0-rc-*

<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.0-rc-*" />
answered on Stack Overflow Aug 19, 2017 by ErikasK
0

If you are using asp.net core 2.0, you need to use pomelo 2.0.0. Asp.net core 2.0 does not work with pomelo 2.1 or higher.

answered on Stack Overflow Nov 30, 2018 by Desi Brust • edited Mar 6, 2019 by Desi Brust

User contributions licensed under CC BY-SA 3.0