InvalidOperationException with EFCore 5 connection that uses Pomelo driver and DbContextOptions
I am trying to utilize a saved connection I have to a context that uses EFCore 5 with the current alpha of the Pomelo.EntityFrameworkCore.MySql driver (version 5.0.0-alpha.2 as of this writing).
When I use a constructor that accepts a string, everything works fine (although I've noticed that I cannot see the value of parameters in the SQL tab, it always shows ='?'
for any of the parameters under Region Parameters
).
But when I use a constructor that accepts DbContextOption, I will instead get the following exception:
InvalidOperationException: Cannot locate type Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions in assembly C:\Users\cyber\.nuget\packages\Pomelo.EntityFrameworkCore.MySql\5.0.0-alpha.2\lib\netstandard2.1\Pomelo.EntityFrameworkCore.MySql.dll.
with a stack trace of:
at LINQPad.Drivers.EFCore.OptionsBuilderBuilder.Create(IConnectionInfo cxInfo, String assemblyFilename, String typeWithUseMethod, String methodName, String optionsBuilderType) at LINQPad.Drivers.EFCore.OptionsBuilderBuilder.ForMySQLPomelo(IConnectionInfo cxInfo) at LINQPad.Drivers.EFCore.OptionsBuilderBuilder.Get(IConnectionInfo cxInfo) at LINQPad.Drivers.EFCore.StaticDriver.GetContextConstructorArguments(IConnectionInfo cxInfo)
This only started to happen once I switched to the alpha Pomelo driver to use EFCore 5. I have no issues with using the DbContextOptions constructor outside of LINQPad.
Comments
It looks like they've changed the name of that type to MySqlDbContextOptionsBuilderExtensions.
I'll get a fix into the next build.
When is this going to get fixed? I can't use the application, I am using MySql.Data.EntityFrameworkCore version 8.0.22.
Thank you!
Have you tried the latest beta?
https://www.linqpad.net/linqpad6.aspx#beta
Yes, I did. It still doesn’t work. This is the error I am getting.
The version I am using is v6.12.3 (X64) Beta Update Stream.
Sorry - fixing this was more involved than I thought. UseMySQL now requires a mandatory ServerVersion.
Try again - the beta will auto-update itself.
Seems that there is the same problem with Npgsql, they have also changed name of type NpgsqlDbContextOptionsExtensions to NpgsqlDbContextOptionsBuilderExtensions. Will be waiting for fix) Thanks!
I only just now started using the beta again, I can confirm that using the Pomelo EF Core driver with EF Core 5 is indeed working now.