Hi, all unit tests shipped with aspnet zero project are failing with following exception:
"format of the initialization string does not conform to specification starting at index 0"
Please suggest.
thanks, Gaurav
12 Answer(s)
-
0
Hi, can you share the full stacktrace of the exception?
Also,
- What is your product version?
- What is your product type (Angular or MVC)?
- What is product framework type (.net framework or .net core)?
-
0
Hi,
Please find below my comments in bold:
What is your product version? Regular What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .net core 2.2
StackTrace: System.ArgumentException : Format of the initialization string does not conform to specification starting at index 0. Stack trace: at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary
2 parsetable, String connectionString, Boolean buildChain, Dictionary
2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary2 synonyms) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef
1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func
3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable
1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at lambda_method(Closure ) at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable
1.GetEnumerator() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable1 results, QueryContext queryContext, IList
1 entityTrackingInfos, IList1 entityAccessors)+MoveNext() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor
1.EnumeratorExceptionInterceptor.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at System.Linq.Enumerable.First[TSource](IEnumerable
1 source) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_11.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable
1 source, Expression1 predicate) at PatientPortal.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/DefaultEditionCreator.cs:line 26 at PatientPortal.Migrations.Seed.Host.DefaultEditionCreator.Create() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/DefaultEditionCreator.cs:line 21 at PatientPortal.Migrations.Seed.Host.InitialHostDbBuilder.Create() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/InitialHostDbBuilder.cs:line 16 at PatientPortal.Migrations.Seed.SeedHelper.SeedHostDb(PatientPortalDbContext context) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 26 at PatientPortal.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action
1 contextAction) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 42 at PatientPortal.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 18 at PatientPortal.EntityFrameworkCore.PatientPortalEntityFrameworkCoreModule.PostInitialize() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/EntityFrameworkCore/PatientPortalEntityFrameworkCoreModule.cs:line 83 at System.Collections.Generic.List1.ForEach(Action
1 action) at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 155 at Abp.TestBase.AbpIntegratedTestBase`1.InitializeAbp() in D:\Github\aspnetboilerplate\src\Abp.TestBase\TestBase\AbpIntegratedTestBase.cs:line 53 at PatientPortal.Tests.AppTestBase..ctor() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/test/PatientPortal.Tests/AppTestBase.cs:line 27 at PatientPortal.Tests.Auditing.AuditLogAppService_Tests..ctor() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/test/PatientPortal.Tests/Auditing/AuditLogAppService_Tests.cs:line 21
-
0
Your connection string is invalid.
-
0
HI,
Thats right, its invalid connection string error but its failing for in-memory database only for unit test project ("Data Source=":memory:".) We haven't changed any shipped code and only trying to run all unit tests thats come with the project. Can you suggest.
-
0
@MellowoodMedical Can you share your project to: [email protected]?
-
0
Hi,
Shared project at above mentioned email address.
Thanks, Gaurav Singh
-
0
I can't download your project, can you send it directly via the gmail attachment?
-
0
@MellowoodMedical
I have downloaded and tested your project.
set abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true; to solve your problem.
public PatientPortalTestModule(PatientPortalEntityFrameworkCoreModule abpZeroTemplateEntityFrameworkCoreModule) { abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true; }
-
0
Thanks, tests are running now.
-
0
Hi,
I am also using the regular aspnet core (2.2)/angular solution v6.9.1 and also have most of my unit tests failing -- most with the below error. Note that I have disabled multi-tenancy.
Any help would be appreciated.
Oh, and also, why was the above change needed for @MellowoodMedical's solution?
Thanks, Genaro
Test Name: Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests.Should_Get_OrganizationUnits Test FullName: Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests.Should_Get_OrganizationUnits Test Source: C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.GraphQL.Tests\OrganizationUnits\OrganizationUnitQuery_Tests.cs : line 11 Test Outcome: Failed Test Duration: 0:00:00.001
Result StackTrace: at Cssc.LessToRemember.Migrations.Seed.Host.DefaultSettingsCreator.Create() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\Host\DefaultSettingsCreator.cs:line 27 at Cssc.LessToRemember.Migrations.Seed.Host.InitialHostDbBuilder.Create() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\Host\InitialHostDbBuilder.cs:line 19 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.SeedHostDb(LessToRememberDbContext context) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 26 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action
1 contextAction) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 42 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 18 at Cssc.LessToRemember.EntityFrameworkCore.LessToRememberEntityFrameworkCoreModule.PostInitialize() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\EntityFrameworkCore\LessToRememberEntityFrameworkCoreModule.cs:line 61 at System.Collections.Generic.List
1.ForEach(Action1 action) at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 155 at Abp.TestBase.AbpIntegratedTestBase
1.InitializeAbp() in D:\Github\aspnetboilerplate\src\Abp.TestBase\TestBase\AbpIntegratedTestBase.cs:line 53 at Cssc.LessToRemember.Test.Base.AppTestBase1..ctor() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.Test.Base\AppTestBase.cs:line 30 at Cssc.LessToRemember.GraphQL.Tests.GraphQLTestBase
2..ctor() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.GraphQL.Tests\GraphQLTestBase.cs:line 36 at Cssc.LessToRemember.GraphQL.Tests.GraphQLTestBase`1..ctor() at Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests..ctor() Result Message: System.NullReferenceException : Object reference not set to an instance of an object. -
0
Note to maintainers regarding the error faced by @gpicazo:
InitialHostDbBuilder.Create
is called beforeDefaultTenantBuilder.Create
in SeedHelper.cs, sodefaultTenant
isnull
. -
0
@aaron - thanks, that worked