Skip to content
New issue

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. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.3.0 not working with MySql #137

Closed
SergejNe opened this issue Sep 7, 2018 · 15 comments
Closed

Release 3.3.0 not working with MySql #137

SergejNe opened this issue Sep 7, 2018 · 15 comments
Labels

Comments

@SergejNe
Copy link

SergejNe commented Sep 7, 2018

I downloaded the Project 'ExtCore framework 3.3.0 sample web application that uses a database'.
Then I replaced SQLite with MySql.

The project was compiled without errors.

But with request I get the error:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLGK01K4H0K5", Request id "0HLGK01K4H0K5:00000003": An unhandled exception was thrown by the application.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load type 'MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLTypedRelationalValueBufferFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' because the parent type is sealed.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeAssembly.get_DefinedTypes()
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable1 parts, ControllerFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetControllerTypes() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.BuildModel() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context) at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.UpdateCollection() at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.get_ActionDescriptors() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.GetTreeRouter() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)
System.TypeLoadException: Could not load type 'MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLTypedRelationalValueBufferFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' because the parent type is sealed.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 2.4005ms 500

@Xarkam
Copy link
Contributor

Xarkam commented Sep 7, 2018

Hello,
Have you created a MySql project like the Extension.Data.EntityFramework.Sqlite project?

@SergejNe
Copy link
Author

SergejNe commented Sep 7, 2018

I have changed Extension.Data.EntityFramework.Sqlite to Extension.Data.EntityFramework.MySql in all files.

@Xarkam
Copy link
Contributor

Xarkam commented Sep 7, 2018

You must also change in csproj files the line <PackageReference Include="ExtCore.Data.EntityFramework.Sqlite" Version="3.3.0" />to <PackageReference Include="ExtCore.Data.EntityFramework.MySql" Version="3.3.0" />
After, you need to make dotnet restore

@SergejNe
Copy link
Author

SergejNe commented Sep 7, 2018

The same error.

$dotnet restore
Restore completed in 45.09 ms for /test/src/Extension.Data.Abstractions/Extension.Data.Abstractions.csproj.
Restore completed in 45.09 ms for /test/src/Extension.Data.Entities/Extension.Data.Entities.csproj.
Restore completed in 45.09 ms for /test/src/Extension.Data.EntityFramework.MySql/Extension.Data.EntityFramework.MySql.csproj.
Restore completed in 45.1 ms for /test/src/Extension/Extension.csproj.
Restore completed in 5.58 ms for /test/src/WebApplication/WebApplication.csproj.

test$ dotnet run --project "/test/src/WebApplication/WebApplication.csproj"

info: ExtCore.WebApplication[0]
Discovering and loading assemblies from DependencyContext
info: ExtCore.WebApplication[0]
Assembly 'WebApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Data, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Data.Abstractions, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Data.Entities.Abstractions, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Data.EntityFramework, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Data.EntityFramework.MySql, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Infrastructure, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Mvc, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.Mvc.Infrastructure, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'ExtCore.WebApplication, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'MySql.Data, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' is discovered and loaded
info: ExtCore.WebApplication[0]
Discovering and loading assemblies from path '/home/sgepfner/c_sharp/test/src/WebApplication/Extensions'
info: ExtCore.WebApplication[0]
Assembly 'Extension.Data.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'Extension.Data.EntityFramework.MySql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'Extension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Assembly 'Extension.Data.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is discovered and loaded
info: ExtCore.WebApplication[0]
Executing ConfigureServices action 'ExtCore.Data.Actions.AddStorageAction'
info: ExtCore.WebApplication[0]
Executing ConfigureServices action 'ExtCore.Data.EntityFramework.Actions.AddStorageContextAction'
info: ExtCore.WebApplication[0]
Executing ConfigureServices action 'ExtCore.Mvc.Actions.AddStaticFilesAction'
info: ExtCore.WebApplication[0]
Executing ConfigureServices action 'ExtCore.Mvc.Actions.AddMvcAction'
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/home/sgepfner/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: ExtCore.WebApplication[0]
Executing Configure action 'ExtCore.Mvc.Actions.UseStaticFilesAction'
info: ExtCore.WebApplication[0]
Executing Configure action 'ExtCore.Mvc.Actions.UseMvcAction'
info: ExtCore.Mvc[0]
Executing UseMvc action 'Extension.Actions.UseMvcAction'
Hosting environment: Development
Content root path: /home/sgepfner/c_sharp/test/src/WebApplication
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

After request:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:5000/
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLGKJ6MBS9CM", Request id "0HLGKJ6MBS9CM:00000001": An unhandled exception was thrown by the application.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load type 'MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLTypedRelationalValueBufferFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' because the parent type is sealed.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeAssembly.get_DefinedTypes()
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable1 parts, ControllerFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetControllerTypes() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.BuildModel() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context) at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.UpdateCollection() at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.get_ActionDescriptors() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.GetTreeRouter() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)
System.TypeLoadException: Could not load type 'MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLTypedRelationalValueBufferFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' because the parent type is sealed.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 124.2594ms 500

@Xarkam
Copy link
Contributor

Xarkam commented Sep 7, 2018

Do not forget to copy the new mysql dll on the old one.

@SergejNe
Copy link
Author

SergejNe commented Sep 7, 2018

  1. I deleted everything (.dll in each subdirectory)
  2. I compiled the project new.
  3. Then I copied all DLLs into directory 'Extensions'.
  4. The project started new.

The same result as early -> not working with the same error.

I added line in WebApplication.csproj (latest version of EFC - 8.0.12)

And now comes other error:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLGKKS096ARA", Request id "0HLGKKS096ARA:00000001": An unhandled exception was thrown by the application.
System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory..ctor(Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1, Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMapper)'.

@SergejNe
Copy link
Author

SergejNe commented Sep 7, 2018

Here is the project.
test.zip

DB
Table:
CREATE TABLE Items (
Id INT(11) NOT NULL AUTO_INCREMENT,
Name VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (Id)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
AUTO_INCREMENT=2;

INSERT INTO Items (Name) VALUES ('Test');

@Xarkam
Copy link
Contributor

Xarkam commented Sep 7, 2018

So, this is a MySQL .NET Connector bug: https://bugs.mysql.com/bug.php?id=89855.
#137 (comment) show the bug.

See: dotnet/efcore#11078

Use https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql waiting for the Oracle patch

@DmitrySikorsky
Copy link
Member

So, can we have current implementation working for now? I mean using MySql.Data.EntityFrameworkCore 8.0.12, without moving to Pomelo.EntityFrameworkCore.MySql.

@Xarkam
Copy link
Contributor

Xarkam commented Oct 17, 2018

Hi, @DmitrySikorsky

The answer is no.

The bug is still open at Oracle.
And from what I see, Pomelo is also a victim of this problem with EF.Core 2.1.2 (dotnet/efcore#11078 (comment))

Everyone depends on Oracle's goodwill, but he does not seem to have any.

@DmitrySikorsky
Copy link
Member

Oh. So now we just keep it as is? Is it the best option?

@postb99
Copy link

postb99 commented Oct 18, 2018

Hi Dmitry, yes, the issue can be closed with a significant label such as "bug-external" or "closed-external". On the Oracle bug, someone lately commented that the Enterprise Oracle version fixes it, but they're not willing to copy the fix to the community version... not surprising but sad.

@Xarkam
Copy link
Contributor

Xarkam commented Oct 29, 2018

@DmitrySikorsky
Copy link
Member

I've updated MySQL provider version to 8.0.13. As I understand from the @Xarkam 's link, this issue might be fixed in the 4.0.0-alpha2. Could somebody, who has MySQL installed, verify that? Thanks!

@Xarkam
Copy link
Contributor

Xarkam commented Mar 18, 2019

Updating: EF version 2.1 is don't supported by mysql connector befor version 8.0.13.
The version 8.0.13 and later support only .NET Standard 2.0
You must target your application into netstandard2.0 for using mysql connector.

Look this page for versions compatibilities: https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants