Using SqlServer when running auto-test
I would like to use Sql Server when running auto-test.
I have added the SqlServer2014Express service on the environments tab.
I'm using this connection string "Server=(local)\SQL2014;Database=TestDb;User ID=sa;Password=Password12!"
I'm using the EntityFramework database initialiser "DropCreateDatabaseAlways".
I get this error:
System.Data.SqlClient.SqlException : 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)
Any thoughts?
Bjarne
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

Support Staff 1 Posted by Feodor Fitsner on 27 Feb, 2015 02:28 PM
Will take a look.
-Feodor
Support Staff 2 Posted by Feodor Fitsner on 27 Feb, 2015 03:08 PM
Do you see these two messages (or at least the first one) in a build log?
3 Posted by Bjarne Riis on 27 Feb, 2015 04:27 PM
Hi Feodor
Thank you taking a look :-)
Yes, I see both those messages.
Regards
Bjarne
Support Staff 4 Posted by Feodor Fitsner on 27 Feb, 2015 05:35 PM
Are you running on Pro or Azure environment?
I did some tests with SQL 2014 and it worked just fine on Pro workers.
Test #1 - deploying DACPAC to a new SQL Server database with msdeploy and then checking database contents with
SqlCommand:appveyor.yml: https://github.com/FeodorFitsner/dacpac-sample/blob/master/appveyor...Test #2 - more extreme - enabling TCP/IP on SQL Server 2014 instance, setting its alias to
(local)and then accessing it withsqlcmd:5 Posted by Bjarne Riis on 02 Mar, 2015 11:57 AM
Hi Feodor
I don’t know if it’s Pro or Azure. The account I’m working on is named ‘LauritzITDevelopment’.
I have found some new information :-)
It appears that the Sql Server works just fine. The real problem seems to be, that when I run the tests, then xunit.console doesn’t load the config file of my test project.
Instead it has loaded its own config file located at c:\Tools\xUnit\xunit.console.clr4.x86.exe.Config.
Feel free to take a look at the build.
https://ci.appveyor.com/project/LauritzITDevelopment/lauritz-lots/build/118 <https://ci.appveyor.com/project/LauritzITDevelopment/lauritz-lots/build/118>
I will keep digging, but any ideas is greatly appreciated :-)
Regards
Bjarne
Support Staff 6 Posted by Feodor Fitsner on 02 Mar, 2015 02:31 PM
Will take a look. As a quick note - make sure app.config for the project with tests has "copy always" set in Visual Studio.
-Feodor
Support Staff 7 Posted by Feodor Fitsner on 02 Mar, 2015 05:54 PM
OK, I did a simple xUnit 2.0 test reading settings and connection string config and it worked like a charm.
Test: https://github.com/FeodorFitsner/xunit-20-tests/blob/master/Xunit20...
App.config: https://github.com/FeodorFitsner/xunit-20-tests/blob/master/Xunit20...
Build results: https://ci.appveyor.com/project/FeodorFitsner/xunit-20-tests/build/...
Note, that
app.configshould have set "Copy always": https://github.com/FeodorFitsner/xunit-20-tests/blob/master/Xunit20... and when project build there must be<assembly>.dll.configin output directory.8 Posted by Bjarne Riis on 03 Mar, 2015 08:31 AM
I did the same thing. Made a new test project in the same solution, and everything works perfectly. Spooky :-)
But al is good. I have a workaround and will keep digging. Thank you for your help !
Regards
Bjarne
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:54 AM.