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
How to Get The Http Post Data in C#
Getting a Request.Headers Value
Changing a C# Delegate's Calling Convention to Cdecl
Linux to Windows Bad Encoding Response
Android Emulator Not Connecting to Localhost API
Document.Ready() Is Not Working After Postback
Serializing Strings Containing Apostrophes with JSON.Net
Using R.Net.Community in .Net Core 2.0 Preview 1
Entity Framework 4.1 Inverseproperty Attribute and Foreignkey
Openssl.Net Porting a Ruby Example to C# (From Railscasts 143 Paypal-Security)
.Net Vs Java Garbage Collector
Using Simple Injector with Unit of Work & Repository Pattern in Windows Form
Navigation Property Without Declaring Foreign Key
Use an Async Callback with Task.Continuewith