zoukankan      html  css  js  c++  java
  • 配置EF链接 MySql 的方法

     

    材料:

    1、MySQL for Visual Studio 1.2.4.msi    

    下载:http://dev.mysql.com/downloads/windows/visualstudio/

    2、mysql-connector-net-6.8.3.msi      

    下载:http://dev.mysql.com/downloads/file.php?id=405442

    EntityFramework.dll、 MySql.Data.dll、 MySql.Data.Entity.EF6.dll

                       可以通过 nugget 获取到

    3、VS2013  (FrameWork4.5)

    步骤:

    1、  创建个vs2013项目,导入EntityFramework.dll、 MySql.Data.dll、 MySql.Data.Entity.EF6.dll

    2、  工具 -> 扩展和更新-> 联网搜索到 “Entity FrameWork Power Tools Beta4“ ,添加这个扩展到VS 2013 里,从新启动VS。

    3、  使用 Code First 生成项目里用的EF 代码。

    4、  安装 MySQL for Visual Studio 1.2.4.msi      VS 访问 MySQL 的驱动。 会出现 【图三】 的数据源选项。

    5、  安装 mysql-connector-net-6.8.3.msi   连接器

    点击 图三 确定按钮,出现: 

    6、注意: 如果报错,请检查是否引入了 EF  dll ;  数据库字段是否存在特殊字符

    7 、 生成完毕后修改 config 文件。

    红框一代码:

    1
    2
    3
    4
      <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>

    红框二代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
        </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.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
      </system.data>

    8、配置完毕,写代码测试。

  • 相关阅读:
    linux C(hello world)最大公约数和最小公倍数
    linux C(undefined reference to `sqrt')
    linux C(hello world)程序调试
    linux C(hello world)
    Google Map 符号
    Google Map 学习过程中的代码
    Google Map 形状显示
    创建 StyledMapType 地图样式
    地图类型
    使用Visual Studio code
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/6155108.html
Copyright © 2011-2022 走看看