MySQL "Network-Related or Instance-Specific Error Occurred While Establishing a Connection to SQL Server"

Why did a network-related or instance-specific error occur while establishing a connection to SQL Server?

Your connection string was probably overriden when you copied your new website version on the server. Please check the connection string in web.config and see if it is valid.

Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not

If someone is having the same issue I just solved it.

I have my database in mysql server not sql. I was using on my command the package Microsoft.EntityFrameworkCore.SqlServer so It wouldn't do the scaffolding. I installed MySql.Data.EntityFrameworkCore, although it has fallen into disuse and tried this command:

Scaffold-DbContext "server=82.223.2.171;port=3306;user=user;password=****;database=db" MySql.Data.EntityFrameworkCore -OutputDir Models -f

Trying to connect to MySQL server: A network-related or instance-specific error occurred while establishing a connection to SQL Server

You must change details in config to use proper driver:

<property name="connection.driver_class">
NHibernate.Driver.MySqlDataDriver
</property>

Some of the examples can be found here: https://www.codeproject.com/Articles/26123/NHibernate-and-MySQL-A-simple-example

MySQL network-related or instance-specific error occurred while establishing a connection to SQL Server

SqlConnection is for SqlServer. To connect to MySql you need to download some drivers and reference it in your project, and use MySqlConnection instead.

Take a look at this question and this CodeProject sample.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

You must connect to MySql witch is specific for MySql Like MySqlConnection for more look this tutorial
or this

A network-related or instance-specific error occurred while establishing a connection to SQL Server(In Asp.net Mvc applciation )

Check you ConnectionString. You definitly got this error because app cannot establish connection with the databse.

As far as you are using MySql, I would recommend you to implement custom membership provider to control all the aspects of authentication, and be able to debug your code. Here is how to proceed: http://msdn.microsoft.com/en-us/library/ms366730%28v=VS.85%29.aspx

If you still want to go with SqlMembershipProvider, try this, hope it helps:

<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear/>
<add name="MySqlMembershipProvider"
type="MySql.Web.Security.MySQLMembershipProvider, mysql.web"
connectionStringName="DAConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/"
autogenerateschema="true"/>
</providers>
</membership>

Found there: http://www.integratedwebsystems.com/2010/02/how-to-setup-and-configure-mysql-membership-provider-6-2-2-porting-to-mono-part-2-of-3/



Related Topics



Leave a reply



Submit