1.UI项目和数据库访问层添加MYSQL.DATA.DLL
2. 在<appSettings/>下添加
<system.data>
<DbProviderFactories>
<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.2.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
3.调用DbProviderFactories.GetFactory("MySql.Data.MySqlClient")就可以了