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



  • 相关阅读:
    JavaBasics-15-多线程
    4.10 SpringCloud微服务技术栈
    4.3 Linux操作系统_Unix操作系统
    4.2 互联网项目架构演进
    4.1 微服务框架_引言
    4.6 Redis
    SpringBoot
    docker-dockerfile实战构建文件
    docker 安装私有仓库 registry(离线)
    基础K8S搭建(20209.08亲测成功)
  • 原文地址:https://www.cnblogs.com/fer-team/p/6733103.html
Copyright © 2020-2023  润新知