Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

c# - MySQL Connector with EF6 in Visual Studio 2013

I am attempting to connect to MySQL through a C# .NET web MVC application.

My issue is that, when I attempt to add an ADO.NET Entity Data Model, generated from Database, based on my MySQL connection, I get the following error message:

Your project references the latest version of Entity Framework; however, an Entity Framework database provider compatible with this version could not be found for you data connection. Exit this wizard, install a compatible provider, and rebuild your project before performing this action

I'm running the following software, upgrades & add-ons:

  • Visual Studio 2013
  • MySQL Server v5.6.21
  • MySQL For Visual Studio v1.2.3
  • Connector/NET v6.9.4

NuGet packages:

  • EntityFramework v6.1.1
  • MySQL.Data v6.9.3
  • MySQL.Data.Entities v6.8.3.0
  • SQL.Web v6.9.3

My web.config, entityFramework block:

    ..
</system.webServer>
<entityFramework>
  <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
  <providers>
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
  </providers>
</entityFramework>
<runtime>
    ..

I have looked at all other solutions I could find here on SO and generally through google, tried all of them and none of the solutions seems to have worked or have been for very different versions of Connector/NET or other of the programs needed.

Can anyone spot what I am doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same issue. After installing:

  • Visual Studio 2013 Community Edition
  • MySQL for Visual Studio 1.2.3
  • MySQL Connector .NET 6.9.5

I didn't want to reinstall Visual Studio, so after some tests, I found that the folder "C:Program Files (x86)Microsoft Visual Studio 12.0Common7IDEPrivateAssemblies" contained old versions of the following files:

  • MySql.Data.dll
  • MySql.Data.Entity.EF6.dll
  • MySql.Web.dll

After closing Visual Studio, I replaced these files with those in "C:Program Files (x86)MySQLMySQL Connector Net 6.9.5Assembliesv4.5", and now it works!

Note: replace 6.9.5 in the subfolder name above, with the actual version installed in your system.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...