Domanda

I use Entity FrameWork 5.0 and MySql connector 6.7.4 . I have a simple MVC Razor 4 application. When I start my appliaction there is an error like this :

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

I tried that unload and load my MySqlData dll from NuGet but it didn't work. What should I do?

È stato utile?

Soluzione

As you are using EF5 a corollary is that you have to use version 4.5 of the framwework. This then requires that you use version 6.7.4.0 of the MySql connector libraries as you've stated, yet your error implies that you are using version 6.6.5.0 for .Net 4.0.

You need to remove the current version you have and download the correct version from NuGet. Alternatively, you can download directly from the MySql Dev site

Also, make sure that you reference MySql.Data, MySql.Data.Entity and MySql.Web in your application, and that they are all version 6.7.4.0.

You may also need to update the <system.data> section of your web.config. Try this:

<system.data>
    <DbProviderFactories>
        <clear/>
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
</system.data>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top