简体   繁体   中英

mySQL Entity Framework 4.1 Code First ASP.NET connection problem

I have an ASP.NET webforms application with the following Web.config entries so that I can connect to a mySQL database running on the local host:

  <connectionStrings>
    <remove name="LocalMySqlServer"/>
    <!-- <add name="ApplicationServices" connectionString="server=127.0.0.1;uid=root;pwd=mypass;database=MyDB" providerName="MySql.Data.MySqlClient" /> -->
    <add name="ApplicationServices" connectionString="server=127.0.0.1;uid=root;pwd=mypass;database=MyDB" providerName="MySQL Data Provider" />
  </connectionStrings>

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

The user can login with "mypass" but whenever I actually connect to the database I get the following error:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

which indicates that I have a messed up configuration string as an attmpt is being made to a SQL Server using Named pipes.

Can anyone point me in the direction of a solution here please?

我的EF4.1和MySqlConnector 6.4.3的连接字符串如下所示:

<add name="myconnection" connectionString="metadata=res://*/MyDatabase.csdl| res://*/MyDatabase.ssdl|res://*/MyDatabase.msl; provider=MySql.Data.MySqlClient; provider connection string=&quot;server=servername;User Id=root;password=mypassword; Persist Security Info=True;database=mydatabase;Allow Zero Datetime=true;Convert Zero Datetime=true&quot;" providerName="System.Data.EntityClient" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM