0

我在外部服务器上创建并托管了一个 ASP.NET 4,它可以正常运行,但实体框架无法访问 MySQL 数据库。例如,我可以使用 PHP 访问 mysql [只是检查登录名和密码以及数据库名称是否正确],但不能使用 EF。

我的 web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <configSections></configSections>
  <appSettings />
  <!--



  <connectionStrings>
    <add name="ImmoEntities" connectionString="metadata=res://*/Model.ImmoModel.csdl|res://*/Model.ImmoModel.ssdl|res://*/Model.ImmoModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=*****.info;Password=*****;User Id=*****;database=*****&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>


  <system.web>

    <globalization culture="auto:fr-FR" uiCulture="auto:fr-FR" />
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <clear />
        <add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web1.siteMap" />
        <add name="web1" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web1.sitemap" />
        <add name="web" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web.sitemap" />
        <add name="web3" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web3.sitemap" />
        <add name="web4" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web4.sitemap" />
      </providers>
    </siteMap>

    <!-- Web.Config Configuration File -->





    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->

<!----- if i uncommented this section my application cannot run -> 500 internal server error

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
-->


    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->

    <authentication mode="Windows" />
    <httpHandlers>
      <add path="CaptchaImage.axd" verb="GET" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" />
    </httpHandlers>

    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <controls>
        <add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>

        <add tagPrefix="cc1" assembly="MSCaptcha" namespace="MSCaptcha" />

      </controls>
    </pages>

  </system.web>


  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->


  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
  </system.web>




  <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.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

</configuration>

我的 Bin 文件夹包含:

AjaxControlToolkit.dll
FredCK.FCKeditorV2.dll
MSCaptcha.dll
MyApp.dll
MyApp.pdb
MySql.Data.dll
MySql.Data.Entity.dll
MySql.Web.dll
System.ComponentModel.DataAnnotations.dll
System.Core.dll
System.Data.Entity.dll
System.Data.Linq.dll
System.Design.dll
System.Web.DynamicData.dll
System.Web.Entity.dll
System.Web.Extensions.Design.dll
System.Web.Extensions.dll
System.Windows.Forms.dll
System.Xml.Linq.dll

有没有关于如何解决这个问题的建议?

4

0 回答 0