0

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:

  1. Data Source or Server Name or IP address is correct. it is: SKI-PC\

  2. I'm sure that my instance name is correct.

  3. 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=&quot;data source=SKI-PC\SEP;initial catalog=Restaurant;user id=sa;password=;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Saman Gholami
  • 3,416
  • 7
  • 30
  • 71
  • 1
    Try looking [here](https://stackoverflow.com/questions/18060667/why-am-i-getting-cannot-connect-to-server-a-network-related-or-instance-speci) for a possible solution. – Blue Jul 23 '17 at 13:50
  • So how are you telling EF to use that connection string? I prefer to supply it to the constructor of the DbContext as shown [here](https://msdn.microsoft.com/en-us/data/jj592674). – Steve Greene Jul 23 '17 at 15:39

0 Answers0