Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 599
Ron Penton Avatar asked May 15 '17 18:05

Ron Penton


People also ask

Why can't I use EF Core with pomelo?

Since the exception complains about the method not being implemented, it is very likely, that you are not running Pomelo with EF Core 3.1 but with a preview of EF Core 5, which is not supported for Pomelo version 3.1.2. @lauxjpn Thanks, I was changing the EF Core version, and I'm trying with EF Core 3.1.2 and it's fine

Why can't I implement the method in pomelo?

Since the exception complains about the method not being implemented, it is very likely, that you are not running Pomelo with EF Core 3.1 but with a preview of EF Core 5, which is not supported for Pomelo version 3.1.2. Sorry, something went wrong. I tried to downgrade the version to EF and grapefruit, but it doesn't solve the problem

What is the issue number for pomelo Entity Framework Core?

· Issue #1138 · PomeloFoundation/Pomelo.EntityFrameworkCore.MySql · GitHub Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement.

What is MySQL provider in Entity Framework?

Pomelo.EntityFrameworkCore.MySql is an Entity Framework Core provider built on top of MySqlConnector that enables the use of the Entity Framework Core ORM with MySQL. Let's create a new application using the Console App (.NET Core) template and install the following NuGet package.


1 Answers

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.

like image 138
Ilya Chumakov Avatar answered Nov 03 '22 00:11

Ilya Chumakov