Bug #90306 MySql.Data.EntityFrameworkCore doesn't work in OWIN .NET Framework Projects
Submitted: 5 Apr 2018 3:30 Modified: 19 Jul 2018 20:54
Reporter: Clark Xu Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.10.6 OS:Windows
Assigned to: CPU Architecture:Any
Tags: connector, EFCore

[5 Apr 2018 3:30] Clark Xu
Description:
MySql.Data.EntityFrmeworkCore doesn't work with EFCore 2.0.0+ in an OWIN hosting .NETFramework project, with exception:

Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.EntityFrameworkCore, Version=1.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.EntityFrameworkCore, Version=1.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 (Fully-specified)
LOG: Appbase = file:///C:/Projects/PackagesVersionTest/NetFrameworkWeb/NetFrameworkWeb2/
LOG: Initial PrivatePath = C:\Projects\PackagesVersionTest\NetFrameworkWeb\NetFrameworkWeb2\bin
Calling assembly : MySql.Data.EntityFrameworkCore, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\PackagesVersionTest\NetFrameworkWeb\NetFrameworkWeb2\web.config
LOG: Using host configuration file: C:\Users\cxu\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.EntityFrameworkCore, Version=1.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/3839e386/7cc4b647/Microsoft.EntityFrameworkCore.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/3839e386/7cc4b647/Microsoft.EntityFrameworkCore/Microsoft.EntityFrameworkCore.DLL.
LOG: Attempting download of new URL file:///C:/Projects/PackagesVersionTest/NetFrameworkWeb/NetFrameworkWeb2/bin/Microsoft.EntityFrameworkCore.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

If set up assembly-binding to EFCore 2.0.1, will get:
Could not load type 'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute' from assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

How to repeat:
How to Reproduce:

In any empty ASP.NET(.NETFramework 4.*) project, install nuget packages of Microsoft.Owin.Host.SystemWeb 4.0.0, MySql.Data.EntityFrameworkCore 6.10.6+ and Microsoft.EntityframeworkCore 2.0.1+

Add Startup.cs with code:

using Owin;
namespace NetFrameworkWeb
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.Run(async (context) =>
           {
               await context.Response.WriteAsync("Hello World!");
           });
        }
    }
}

Press Ctrl+F5 to run. Then will get server error page.

Suggested fix:
Fix the PackageReferences of MySql.Data.EntityFrameworkCore
[5 Apr 2018 7:35] Chiranjeevi Battula
Hello Clark,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2017 and Connector/NET 6.10.6 version.
Could you please provide repeatable test case (exact steps/sample project, screenshot etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[5 Apr 2018 7:35] Chiranjeevi Battula
Screenshot

Attachment: Bug_90306.PNG (image/png, text), 97.77 KiB.

[5 Apr 2018 10:06] Clark Xu
Hi Chiranjeevi,
Thanks for your quick response!

I have uploaded a sample project. Also I saw your screenshot and noticed you were testing on a .NetCore application. Could you please change to try to reproduce on an .Net Framework 4.7.1 application or using my uploaded project?

Cheers,
Clark
[5 Apr 2018 11:16] Chiranjeevi Battula
Hello Clark,

Thank you for the feedback.
Verified this behavior on Visual Studio 2017 (ASP.Net) and Connector/NET 6.10.6 version.

Thanks,
Chiranjeevi.
[19 Jul 2018 20:54] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 6.10.8 and 8.0.13 release, and here's the changelog entry:

The Microsoft.EntityFrameworkCore assembly (with EF Core 2.0) was not
loaded and generated an error when the application project was built with
any version of .NET Framework. This fix ensures the following support: 

* EF Core 1.1 with .NET Framework 4.5.2 only 
* EF Core 2.0 with .NET Framework 4.6.1 or later

Thank you for the bug report.