添加 mysql dll 引用

WebConfig 配置:

1.先添加connectionstrings,providerName 换成 mysql的

<connectionStrings>
    <add name="ECSWebDb" connectionString="User Id=xxx;server=.;Database=xxx;pwd=xxx;Persist Security Info=True;"
         providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>

2.EF 添加Provider的 配置

1
2
3
4
5
6
7
8
9
10
11
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mysqllocaldb" />
      </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"/>
    </providers>
  </entityFramework>

3. system.data 增加 DbProviderFactories

1
2
3
4
5
6
<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.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
posted on 2019-01-03 16:06  红磨坊后的白桦树  阅读(214)  评论(0编辑  收藏  举报