Интеграционные тесты с использованием localdb с ошибками Visual Studio Online - "аутентификация в автономной базе данных" должна быть установлена на 1
Я использую localdb для некоторых модульных тестов интеграции Entity Framework. Я реализовал стандартную конфигурацию сборки и после первоначальных проблем прочитал, что я должен инициализировать и запустить локальную базу данных SQL. Для этого я добавил следующее для тестирования проекта после сборки:
"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
но я получал ошибки локально и в Visual Studio Online Build, как:
The sp_configure value 'contained database authentication'
must be set to 1 in order to create a contained database.
You may need to use RECONFIGURE to set the value_in_use.
Поэтому после некоторого исследования я добавил следующее.
sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"
sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"
Это исправлено локально, но в VSO build agent все равно появляются ошибки. Похоже, что localdb инициализирован ОК, но затем SQLCMD может найти только что созданный экземпляр сервера. Войдите ниже.
"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"
sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"
LocalDB instance "V12.0" created with version 12.0.2000.8.
LocalDB instance "V12.0" started.
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): Error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsetting
Любая помощь будет принята с благодарностью.