I'm working on a project using SQL Server 2008 Express. I had an instance called SQLEXPRESS
and I used to connect to the DB via this connexion string :
<add name="MyConn" connectionString="metadata=res://*/MyDataModel.csdl|res://*/MyDataModel.ssdl|res://*/MyDataModel.msl;provider=System.Data.SqlClient;
provider connection string="data source=PCNAME\SQLEXPRESS;initial catalog=DbName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
This connection string was generated by .edmx
file (I'm working on an ASP.NET MVC project, database first, and Entity Framework) and it worked fine.
I recently installed SQL Server 2016 with a Developer Licence. During the install process, I used the default instance, which is MSSQLSERVER
. For information, the generated InstanceID is MSSQL13.MSSQLSERVER
.
I have a SQL project in my solution to regenerate my tables on my new SQL Server; I could connect easily to the server via the wizard.
I also used SQL Server Management Studio to verify everything was fine on the server, and it works perfectly (tables are generated, connection was OK).
However, my code is unable to connect to the server and systematically failed to the first call with error 26 - can't locate server instance
Here is what I've tried so far:
- Change the
data source
parameter of the connexion string tolocalhost
,.
,.\MSSQLSERVER
,.\PCNAME
,PCNAME.MSSQLSERVER
,PCNAME.MSSQL13.MSSQLSERVER
,DOMAIN.MSSQLSERVER
,DOMAIN\PCNAME
=> Doesn't work - Verify SQL Service are running => They are
- Create an
.udp
file, connect to my server, and copy/paste the generated connection string :Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=PCNAME
=> Doesn't work - Regenerate my .edmx file (and the connection stirng) => Doesn't work
- Verify this suggestion => It was already correct
Why does all the connection wizards seems to work (SSMS,
.udl
file, .edmx
generator, my DB project), whereas my code is unable to reach the server? I didn't change any line of code.
EDIT : The crazy thing is I have a log database on the same server, the connexion string is
<add name="NLogConn" connectionString="Data Source=localhost;initial catalog=DBLOG;integrated security=True" providerName="System.Data.SqlClient" />
And it is actually logging the network error !! So is it really a connection string error or an EF error ? I'm using the latest EF version, 6.1.3 on each project referencing EF (The main and the DAL layers)