• EF切换到Mysql数据库,更改web.config


    1)引用:

      MySql.Data.dll,MySql.Data.Entity.dll,MySql.Data.Entity.EF6.dll

    2)添加:

    <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.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
    </system.data>


    3)更改数据库连接字符串:

    <connectionStrings>
    <!--<add name="WechatServiceContext" connectionString="Data Source=.ms2008;Initial Catalog=Shares;Persist Security Info=True;User ID=sa;Password=sasasa;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>-->
    <add name="WechatServiceContext" connectionString="Data Source=127.0.0.1;port=3306;Initial Catalog=shares;user id=root;password=root;Charset=utf8" providerName="MySql.Data.MySqlClient" />
    </connectionStrings>


    4)增加

    <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
    <parameters>
    <parameter value="mssqllocaldb" />
    </parameters>
    </defaultConnectionFactory>
    <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
    </entityFramework>



  • 相关阅读:
    移动 ProgramDataPackage Cache 文件夹
    Visual Studio 2017
    微信小程序 View:flex 布局
    echarts 模拟迁徙
    树莓派3 Windows 10 IoT Core
    Lumia 830 win10m 启用触摸按键
    青岛旅游
    <孤独者生存(小小辛巴投资手记)>读书笔记
    Python.Unix和Linux系统管理指南
    <低风险投资之路>读书笔记
  • 原文地址:https://www.cnblogs.com/fer-team/p/6733103.html
Copyright © 2020-2023  润新知