hanaim-devops / PriemChecker

0 stars 0 forks source link

Error bij gebruik database; lijkt de connection string (al lijkt die ook goed #1

Open bartvanderwal opened 1 month ago

bartvanderwal commented 1 month ago

Ik krijg bij testen via Swagger UI op eindpoint isPrime een error Format of the initialization string does not conform to specification starting at index 0.hieronder de volledige stacktrace.

De code op regel 11 in MemoizingPriemChecker.cs waar de error start qua eigen code is:

var existingResult = context.PriemCheckResultaten
            .FirstOrDefault(r => r.priemKandidaatWaarde == number);

De gebruiikte connectionstring uit appsettings.Development.json is: "DefaultConnection": "Server=localhost,1433;Database=PriemCheckDb;User Id=sa;Password=Your_password123;TrustServerCertificate=True;"

De volledige stack trace:

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
   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, Dictionary`2 synonyms, Boolean useOdbcRules)
   at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
   at Microsoft.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.<>c.<get_IsMultipleActiveResultSetsEnabled>b__7_0(String cs)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.get_IsMultipleActiveResultSetsEnabled()
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerCompiledQueryCacheKeyGenerator.GenerateCacheKey(Expression query, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
   at PrimeChecker.MemoizingPriemChecker.IsPriemgetal(Int32 number) in /Users/bartvanderwal/Library/CloudStorage/OneDrive-HAN/MDO/PriemChecker/PriemCheckerLibrary/MemoizingPriemChecker.cs:line 11
   at WebPriemChecker.Program.<>c.<Main>b__0_2(IPriemChecker priemgetalChecker, Int32 getal) in /Users/bartvanderwal/Library/CloudStorage/OneDrive-HAN/MDO/PriemChecker/WebPriemChecker/Program.cs:line 52
   at lambda_method2(Closure, Object, HttpContext)
   at Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)