I have an ASP.NET application that I would like to download to a host that offers a MySQL database. I am using Visual Studio 2012, .NET 4.5, Entity Framework 5.0, and I have installed MySQL for Visual Studio 1.0.2. I tried to connect to a local MySQL server, but I ran into some problems.
At first I referred to MySql.Dataand MySql.Data.Entityin version 6.6.5.0 in my project. But when I tried to do Update-Databasein the package manager console, I got the following error:
System.DateTime System.Data.Entity.Migrations.Model.InsertHistoryOperation.get_CreatedOn()
This seems like a problem for Entity Framework 5.0 and earlier versions of Connector / .Net, the Visual Studio MySQL Connector. Since the process was one of the discoveries, I, unfortunately, cannot remember how my project came to the link MySql.Dataand MySql.Data.Entityversion 6.6.5.0.
I removed the links and then downloaded and referenced the same assemblies in version 6.7.4.0 using NuGet. This resolved the error I received earlier, but now Update-Databasegives me the following error:
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 manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I solved this problem by including a specific in my Web.Config file DbProviderFactory:
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<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>
If I do not use the tag remove, I get an error:
Column 'InvariantName' is constrained to be unique. Value 'MySql.Data.MySqlClient' is already present.
, , - - DbProviderFactory, 6.6.5.0 MySQL. , 6.6.5.0 .
MySQL, - - , . , 6.6.5.0- DbProviderFactory, , , , , , - -.
, , , , ( ) 6.6.5.0:

NuGet, 6.7.4.0:

, .