转 ef中使用my步骤--Entity Framework 6 with MySql

原文:http://lvasquez.github.io/2014/11/18/EntityFramework-MySql/

For the Entity Framework 6 support we need to have this requirements

  • MySQL Connector/Net 6.8.x
  • MySQL Server 5.1 or above
  • Entity Framework 6 assemblies
  • .NET Framework 4.0 or above

I will use the concept of DataBase First but without using the Visual Studio wizard to create the Edmx file, so instead of that, I will do it manually. I will create a Console Application, so first install the Entity Framework via Nuget Package

Install-Package EntityFramework
Install-Package MySql.Data.Entity.EF6

Add the connection string in the app.confingthe app.confing should be like this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="MonkeyFist" connectionString="server=localhost;user id=root;password=mypass;database=mydb" providerName="MySql.Data.MySqlClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
<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.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
时间: 2024-08-07 12:51:39

转 ef中使用my步骤--Entity Framework 6 with MySql的相关文章

Entity Framework 6 with MySql

    MySQL Connector/Net 6.8.x MySQL Server 5.1 or above Entity Framework 6 assemblies .NET Framework 4.0 or above   参考文档 Entity Framework 6 with MySql 在Entity Framework中使用MySQL HowTo: Using MySQL for Visual Studio in you first ASP.NET MVC Application

让EF飞一会儿:如何用Entity Framework 6 连接Sqlite数据库

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 获取Sqlite 1.可以用NuGet程序包来获取,它也会自动下载EF6 2.在Sqlite官网上下载对应的版本:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.

采用MiniProfiler监控EF与.NET MVC项目(Entity Framework 延伸系列1)

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 前言 Entity Framework 延伸系列目录 今天来说说EF与MVC项目的性能检测和监控 首先,先介绍一下今天我们使用的工具吧. MiniProfiler~ 这个东西的介绍如下: MVC MiniProfiler是Stack Overf

Entity Framework 6+ 连接Mysql

好吧.这个博客开不开的 我感觉.. 都一样了. 前言: 公司改造Sqlserver ->Mysql Sql2016老夫对不住你啊.. 好 前沿结束. 需要的家伙: 1.mysql-for-visualstudio 2.mysql-connector-net 3.mysql-connector-odbc 4.Vs(史上最强大的IDE没有之一 爱谁谁没有面子) 操作步骤: 1.安装我上面说的这些家伙(如果有就跳过) 2.冲一杯茶开始采坑 3.系统提示 没有Ef6+ 邮件Nuget管理搜索Entity

ABP .Net Core Entity Framework迁移使用MySql数据库

一.迁移说明 ABP模板项目Entity Framework Core默认使用的是Sql Server,也很容易将数据库迁移到MySQL,步骤如下. 二.迁移MySQL步骤 1. 下载项目 请到 http://aspnetboilerplate.com/Templates 下载一个新的项目,选择ASP.NET Core 2.x标签,Target Framework:选中.Net Core就可以了. 2. 移除默认SQL Server相关包 在EntityFrameworkCore项目下移除包Mi

Entity Framework系列教程汇总

阅读目录 一.EntityFramewoke入门教程系列 二.EF CodeFirst系列 翻译自http://www.entityframeworktutorial.net/,使用EF几年时间了,一直没有系统总结过,所以翻译这一系统文章作为总结,由于英语功底有限,翻译的可能有些问题,欢迎指正. 回到顶部 一.EntityFramewoke入门教程系列 Entity Framework入门教程(1)---Entity Framework简介 Entity Framework入门教程(2)---E

Entity Framework中IQueryable, IEnumerable, IList的区别

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 使用工具追踪EF生成的SQL 使用Entity Framework等ORM框架的时候,SQL对于使用者来说是透明的,往往很多人也不关心ORM所生成的SQL,然而系统出现性能问题的时候就必须关注生成的SQL以发现问题所在. 使用过Toplink的

在服务器中使用 Entity Framework 的 Migration 更新数据库

在开发环境中,每次我们对要对数据库进行更改,比如增加修改表字段等.改好Entity类后,我们只需在Nuget程序包管理控制台运行 update-database 脚本却可: update-database Entity Framework提供的这个Migration功能非常方便,基本上不用再打开Sql Server Management Studio了.那么如何在发布环境(服务器)中同步我们对数据库的修改呢? 一种方法是在运行 update-database 脚本加上 -verbose 或 -s

Entity Framework中IQueryable, IEnumerable, IList的区别[转]

使用工具追踪EF生成的SQL 使用Entity Framework等ORM框架的时候,SQL对于使用者来说是透明的,往往很多人也不关心ORM所生成的SQL,然而系统出现性能问题的时候就必须关注生成的SQL以发现问题所在. 使用过Toplink的朋友知道很只要设置日志打印级别=FINE就可以配置使之生成的SQL在服务器中打印出来,Entiry Framework没有那么幸运,在以前要检测生成SQL的唯一方法是SQL Server Profiler,但使用起来并不方便,结果也不能自动保存到文件中.