实体框架无法连接到数据库

时间:2012-04-16 12:01:17

标签: asp.net mysql entity-framework-4 web-config

我在一个外部服务器上创建并托管了一个ASP.NET 4,它运行正常,但是Entity框架无法访问MySQL DataBase。 我可以使用PHP获取访问mysql的例子[仅检查登录名和密码,以及DB的名称是否更正],但不能使用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

关于如何解决这个问题有什么建议吗?

0 个答案:

没有答案