SQL Server is running over TCP/IP.
When I try to first update-database
PM> update-database
Build started... Build succeeded. ...........
ClientConnectionId:00000000-0000-0000-0000-000000000000 Error
Number:-1,State:0,Class:20 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: SNI_PN11, error: 26 - Error Locating
Server/Instance Specified)
Firewall is correct, rules are added for ports 1433, 1434, 55120.
I have a connection in Visual Studio to SQL Server The connection string in appsettings.json is:
"ConnectionStrings": {
"ProductionManagmentContext": "Server=DESKTOP-MAQO344\\SQLEXPRESS;Database=ProductionManagment.Data;Trusted_Connection=True;MultipleActiveResultSets=true"
Related
I don't know how to connect to my SQL Server (local) from an application on ASP.NET MVC.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Connect to SQL SERVER (DbSetttings.json)
{
"ConnectionStrings": {
"DefaultConnection": "Server=СМОЛЬКИНСЕРГЕЙ\\SERVER;Database=Shop;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
Making creation through ef migrations
EntityFrameworkCore\Add-Migration initial
EntityFrameworkCore\Update-DataBase
enter image description here
I am new and can not understand what the error is
Have you tried changing the connection string as follows:
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=СМОЛЬКИНСЕРГЕЙ\\SERVER;Initial Catalog=Shop;Trusted_Connection=True;MultipleActiveResultSets=true"
}
Notice 'Server' and 'Database' are changed 'Data Source' and 'Initial Catalog'
Although I can connect to the server when I'm using either legacy SqlConnection or Sql Management Studio, I'm not able to make connection to Sql Server via Entity framework. In addition I've check all following things:
Data Source or Server Name or IP address is correct. it is: SKI-PC\
I'm sure that my instance name is correct.
Remote connections are allowed and also there is no firewall.
The error I'm facing is:
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: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
Just for clarifying, my connection string in app.config is:
<add name="MyEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=SKI-PC\SEP;initial catalog=Restaurant;user id=sa;password=;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
here is the connection string
<add name="Tapo_ModelContainer" connectionString="metadata=res://*/filename.csdl|res://*/filename.ssdl|res://*/filename.msl;provider=System.Data.SqlClient;provider connection string='Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=APTapo;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework'" providerName="System.Data.SqlClient" />
The Exception
System.Data.EntityException {"The underlying provider failed on Open."}
inner Exception
"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)"
inner exception
"The system cannot find the file specified"
If i use the normal SqlConnection class, i can connect to the database.
It could be because of the permissions.
in the Authentication section. If you can not write the correct connection string you can use Connect To Database option in Tools menu item and if Test Connection is ok then copy the connection string.
I developed a small project in visual studio 2010. In my project I attach a service-based database named database1.mdf.
My connectionString is :
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True
It works fine on my developer pc but it throws an exception on a client's pc.
Exception is :
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: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
I don't understand what is happening.
Two things need to occur before you can connect to a SQL Server Express database.
SQL Server Express must be installed on the target server. Having the file present isn't sufficient. (This is what the error you're experiencing likely means).
The path to your database file should be an absolute path to rule out the possibility of a file location error.
this connection string is for your developer machine. you share your database on the network. you also must update your connection string by adding ip address of your server.
Consider a new ASP.NET MVC project and haven't done any modifications to the code. I run the application and click the [Log On] link at the top right and try to register a new account. After about a minute it times out with the following:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I am running on Windows Server 2008 R2.
Do you have a local instance of SQL server express installed and running?
Look at your web.config <connectionStrings> element. Within there, you'll see a connection string. Find the server or data source portion, and ensure that you have a server with that name.
It defaults to connectionString="data source=.\SQLEXPRESS. Ensure you tweak that as per your environment.