1. .NET Framework 4.6.1
  2. MySQL Server 5.7
  3. MySQL for Visual Studio 1.2.9
  4. MySQL Connector Net 6.9.12

[引入]

  • MySQL Connector Net 6.9.12\Assemblies\v4.5\MySql.Data.dll
  • MySQL Connector Net 6.9.12\Assemblies\v4.5\MySql.Data.Entity.EF6.dll

ANI > App.config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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.12.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.12.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>

<connectionStrings>
<add name="DBModel" connectionString="Server={0};Port=3306;Database={3};User={1};Password={2};CharSet=utf8;SSL Mode=None;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>

DB Config

  • 位置:Data > DBModel.cs
    1
    Database.Connection.ConnectionString = string.Format(connectionString, "localhost", "userid", "pwd", "database");

DB set_mode

1
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));