本文介绍了在Microsoft Visual Studio 2013中的WinForms启用实体框架6的MySQL(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,我知道,实体框架是访问使用数据集或DataReader的数据库旁边的另一种方法,然后我试图让实体框架6作品在2013年MVS我的MySQL数据库服务器

我打开与.NET框架4.5.1一个WinForms。 (所以我只有App.config中,但项目中没有应用程序/ Web配置)
安装后,我的和

通过

安装的EntityFramework包

When I tried to add ADO.NET Entity Data Model via

Then Entity Connection string is generated -> Tick Save entity connection settings in App.Config as -> Next> ->

Which version of Entity Framework do you want to use?Have option Entity Framework 6.0 but you cannot use it because

How to solve this?

By the way , if you install Entity Framework version 5 in Nuget Package then you might have option Entity Framework 5.0 here and you might success to use Entity Framework 5 but not the version 6.

解决方案

First of all, we don't even need to install the mysql-installer-community-5.7.3.0-m13.msi.

  1. Install the latest mysql-visualstudio-plugin
  2. Install the latest mysql-connector-net
  3. New C# .Net 4.5 Framework WinForms (for 4.0 it should work based on Does Entity Framework 6 support .NET 4.0? )
  4. Install 4 Nuget Packages (follow sequence, if you install Mysql.Data.Entities before EntityFramework, it will resolve dependency and install EntityFramework 6.0.2 but what we need is EntityFramework 6.1.0)

5.If you have tag entityFramework in App.config, please comment it and insert new tag entityFramework in App.config after tag startup

  <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>

6.Add ADO.NET Entity Data Model (as mentioned in question)

7.After Entity Connection string is generated (as mentioned in question) and Tick Save entity connection settings in App.Config as then click Next

8.Choose Your Database Object and Settings (Tables, Views, or Stored Procedures and Functions) (Don't have "Which version of Entity Framework do you want to use?" because I have only one Entity Framework 6.0 provider so direct skip the selection if my only provider is valid)

9.Finish

Congratulations ^^

By the way, you may need to add the .dll files

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

inside this folder

as your project reference for further EF6 functions.

这篇关于在Microsoft Visual Studio 2013中的WinForms启用实体框架6的MySQL(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:27
查看更多