当前位置:Gxlcms > 数据库问题 > 【转】使用EF CodeFirst 同时访问MySql和SqlServer配置

【转】使用EF CodeFirst 同时访问MySql和SqlServer配置

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

connectionStrings> <!--Mysql--> <add name="StatisticContext" connectionString="Data Source=192.168.1.233;port=3306;Initial Catalog=statistic2016;user id=root;password=root;" providerName="MySql.Data.MySqlClient" /> <!--SqlServer--> <add name="DJG_RESModel" connectionString="data source=192.168.1.218;initial catalog=RES_DJG;persist security info=True;user id=sa;password=root-001;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /> </connectionStrings>

 

 

 

4、驱动配置 

<configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

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

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

 

                    

人气教程排行