EF +MYSQL 配置

<?xml version="1.0" encoding="utf-8"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <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>
  <connectionStrings>
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication2-20140212101136.mdf;Initial Catalog=aspnet-WebApplication2-20140212101136;Integrated Security=True"
      providerName="System.Data.SqlClient" />-->
    <add name="StudentInfoEntities" connectionString="DataSource=192.168.3.41;DataBase=StudentInfoEntities;Persist Security Info=True;Character Set=utf8;uid=bel;pwd=bel" providerName="MySql.Data.MySqlClient" />
    <!--<add name="StudentInfoEntities" connectionString="DataSource=192.168.3.60;DataBase=StudentInfoEntities;uid=vsmpuser;Port=337;pwd=vsmp100" providerName="MySql.Data.MySqlClient" />-->
  </connectionStrings>
  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
        <add namespace="Microsoft.AspNet.Identity" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
    <membership>
      <providers>
        <!--
          已在此模板中禁用 ASP.NET 成员身份。请访问以下链接 http://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的 ASP.NET 成员身份支持
        -->
        <clear />
      </providers>
    </membership>
    <profile>
      <providers>
        <!--
          已在此模板中禁用 ASP.NET 成员身份配置文件。请访问以下链接 http://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的 ASP.NET 成员身份支持
        -->
        <clear />
      </providers>
    </profile>
    <roleManager>
      <!--
            已在此模板中禁用 ASP.NET 成员身份角色。请访问以下链接 http://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的 ASP.NET 成员身份支持
        -->
      <providers>
        <clear />
      </providers>
    </roleManager>
    <!--
            如果要部署到具有多个 Web 服务器实例的云环境,
            则应将会话状态模式从 "InProc" 更改为“自定义”。此外,
            还应将名为 "DefaultConnection" 的连接字符串更改为连接到
            SQL Server (包括 SQL Azure 和 SQL  Compact)实例,而不是连接到 SQL Server Express 实例。
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <system.data>
    <DbProviderFactories>
      <!-- 不设置这里会提示找不到提供程序-->
      <add name="MySQL" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"/>
    </DbProviderFactories>
  </system.data>
  <system.webServer>
    <modules>
      <remove name="FormsAuthenticationModule" />
    </modules>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <!-- 默认设置的sql-->
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"  />
    </providers>
  </entityFramework>
</configuration>

EF6+MYSQL CONNECTOR 6.8.0.3+VS 2003+MYSQL SERVER 5.4 CODE FIRST 配置

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。