当前位置:Gxlcms > 数据库问题 > 使用EF连接MySQL数据库

使用EF连接MySQL数据库

时间:2021-07-01 10:21:17 帮助过:27人阅读

<configSections> 2 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 3 </configSections> 4 <entityFramework> 5 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 6 <parameters> 7 <parameter value="mssqllocaldb" /> 8 </parameters> 9 </defaultConnectionFactory> 10 <providers> 11 <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 12 <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> 13 </entityFramework>

 

2. MySQL配置节点
1  <system.data>
2     <DbProviderFactories>
3       <remove invariant="MySql.Data.MySqlClient" />
4       <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" />
5     </DbProviderFactories>
6  </system.data>

 

3. 连接字符串
1 <connectionStrings>
2     <add name="NorthwindConnection" connectionString="Data Source=localhost;port=3306;Initial Catalog=northwind;user id=developer;password=developer;"
3          providerName="MySql.Data.MySqlClient" />
4 </connectionStrings>

 

使用EF连接MySQL数据库

标签:data   structure   int   ssi   tco   northwind   var   连接字符串   nfa   

人气教程排行